saving file

  • Thread starter Thread starter juli
  • Start date Start date
J

juli

I want to save file ,using the SaveFileDialog control, in such way
that uploaded file will be saved always as "text.txt" and always in
c:\Text folder.
How do I do it?
Thank you a lot and Happy new Year!
 
juli said:
I want to save file ,using the SaveFileDialog control, in such way
that uploaded file will be saved always as "text.txt" and always in
c:\Text folder.
How do I do it?

Why do you need a SaveFileDialog when there's no choice?
 
the C# Version:

string allmytext = "blah blah blah";

SaveFileDialog sfd = new SaveFileDialog();

sfd.FileName = @"c:\text\text.txt";

System.IO.StreamWriter sw = new System.IO.StreamWriter(sfd.OpenFile());

sw.Write(allmytext);

sw.Flush();

sw.Close();



Ciaran
 
Ciaran said:
the C# Version:

string allmytext = "blah blah blah";

SaveFileDialog sfd = new SaveFileDialog();

sfd.FileName = @"c:\text\text.txt";

System.IO.StreamWriter sw = new
System.IO.StreamWriter(sfd.OpenFile());
sw.Write(allmytext);

sw.Flush();

sw.Close();

But the user can still change the file name and the directory. My point was
that a dialog that leaves you no option is moot ;-)


Cheers,
 
Joerg,

Read it again. It is BS however fun. It does the same as you wrote.
(There is no sfd.ShowDialog in it)

Cor
 
Cor said:
Joerg,

Read it again. It is BS however fun. It does the same as you wrote.
(There is no sfd.ShowDialog in it)

Yup, I completely missed that! Now that's a funny way to write a file :-D

Cheers,
 
Joerg Jooss said:
Yup, I completely missed that! Now that's a funny way to write a file :-D

be sure that You have "C:\text\"
otherwise it will rise an exception:
"Additional information: Could not find a part of the path
"c:\text\text.txt"."

RGDS PSG
 
psg said:
be sure that You have "C:\text\"
otherwise it will rise an exception:
"Additional information: Could not find a part of the path
"c:\text\text.txt"."

C'mon, use a FileStream and be done with it.

Cheers,
 
Back
Top