Writing data to a file from ASP.NET?

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
 
B

Bruno Alexandre

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
 
V

Vadivel Kumar

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,
 
P

Patrick.O.Ige

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,
 
K

Kevin Jones

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
 
H

Hyun-jik Bae

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 '_'.
 

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

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top