Creating Directories with ASP.NET and C# code

S

Senthil

Con is the file name for a reserved device name(i think
it is for console). So you cannot create a file with
name 'con'. choose some other name

senthil

-----Original Message-----
Hi everyone, I am having a problem with creating directories using the
Directory classes static member function CreateDirectory.

Here is the following code that I am trying to run that is causing the
problem.


string patient_path = @"c:\inetpub\wwwroot\EMRWeb\Patient_Files\3040"
Directory.CreateDirectory(patient_path);
Directory.CreateDirectory(patient_path + @"\RAD");
Directory.CreateDirectory(patient_path + @"\MISC");
Directory.CreateDirectory(patient_path + @"\LAB");
Directory.CreateDirectory(patient_path + @"\CON");



when the following code runs, the last line always gives the following
error:
"could not find a part of the path c:\"


The other CreateDirectory calls create the directories properly, so it must
be something with the name of the path
"c:\inetpub\wwwroot\EMRWeb\Patient_Files\3040\CON"

I have also tried usually the following substitue code to the same thing but
it also gives a error when creating the CON subfolder:

DirectoryInfo dir = new DirectoryInfo(patient_path);
dir.Create();
dir.CreateSubdirectory("RAD");
dir.CreateSubdirectory("MISC");
dir.CreateSubdirectory("LAB");
dir.CreateSubdirectory("CON");


I don't think it is a problem with permissions because the other directories
are created properly, but these are the security and permission settings.
The identity of the asp.net application is running under the default ASPNET
user account created by .NET framework. The ASPNET account has full
controll access
folder "c:\inetpub\wwwroot\EMRWeb\Patient_Files" and the
 
B

Babak Movahed

Thanks.. that did the trick.

Senthil said:
Con is the file name for a reserved device name(i think
it is for console). So you cannot create a file with
name 'con'. choose some other name

senthil


folder "c:\inetpub\wwwroot\EMRWeb\Patient_Files" and the
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top