Writing data to a file from ASP.NET?

  • Thread starter Thread starter Hyun-jik Bae
  • Start date Start date
H

Hyun-jik Bae

I wrote an ASP.NET application which receives data from HTTP client and
stores it to a newly created file by my asp.net page.

Everything works ok except for this statement:

FileStream writer = new FileStream("c:\\dumped\\aaa.dmp",
FileMode.Create);

It causes NotSupportedException with "Specified path format is not
supported".

How can I resolve this problem? Please reply. Thanks in advance.

Hyun-jik Bae
 
c:\\ ????

\\ means in a shared folder

when you using " you dont use \\

should be "c:\dumped\aaa.dmp"

dont forget that u need read/write permitions on c:\dumped
 
You can use \\ but prefix it with @ symbol as like below,

FileStream writer = new FileStream(@"c:\\dumped\\aaa.dmp", FileMode.Create);

And, check that you have write/read permission for that folder.

Thanks,
 
Yes @ escape character in c#
Patrick

Vadivel Kumar said:
You can use \\ but prefix it with @ symbol as like below,

FileStream writer = new FileStream(@"c:\\dumped\\aaa.dmp",
FileMode.Create);

And, check that you have write/read permission for that folder.

Thanks,
 
You can use \\ but prefix it with @ symbol as like below,
FileStream writer = new FileStream(@"c:\\dumped\\aaa.dmp",

In fact it's the other way around:

You can do

FileStream writer = new FileStream(@"c:\dumped\aaa.dmp" ...)

or

FileStream writer = new FileStream("c:\\dumped\\aaa.dmp" ...)

It's the '\' that is the escape character, '\\' escapes the '\' so you
end up with only one '\' or using @ says to ignore escaping i.e don't
treat the single '\' as an escape character,

Kevin
 
Thanks for your answers, Bruno, Augustin, Vadviel, Patrick and Kevin.
I found the cause: whitespaces in filename was the matter. I fixed it by
substituting them to underbar '_'.
 
Back
Top