0

This is the first time I make an asp site. This line of code is working fine on my pc but obviously to make it working on the production server I need to change the reference.

DirectoryInfo dir = new DirectoryInfo(@"C:\Users\Pink\Documents\Visual Studio 2012\Projects\ManagDoc_Framework\Test1_managDoc\Test1_managDoc\Allegati\" + recordIDcreateDir);

I have tried many sort of path combination but I am not getting it right.

I would like to find a solution that makes the code working on both pc, during development, and hosting server without having to change the code.

How should i write the path? Some help will be appreciated.

FeliceM
  • 4,163
  • 9
  • 48
  • 75

1 Answers1

2

Use Server.MapPath method :

The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server.

Additional details on W3schools.com, tutorial I followed, and where I learnt the existence of the above method.

David Khuu
  • 937
  • 3
  • 10
  • 21
  • thanks. this worked: DirectoryInfo dir = new DirectoryInfo(Server.MapPath("/Allegati/") + recordIDcreateDir); – FeliceM Sep 15 '13 at 09:23