.net - Saving file using SaveFileDialog in C# -


i wondering if me please. i'm using savefile, tried reading docs on msdn i'm new , honest find them unclear.

here needing do.

  1. save file default c:\, can done save main directory if it's renamed different, on machine main drive labelled f:\, how direct save if renamed ?

  2. is there option set, file can saved binary? , no other type?

the savefiledialog control won't saving @ all. providing convenient interface display windows' default file save dialog.

1) set property initialdirectory drive you'd show other default. think of other computers might have different layout. default windows save directory used last time , present again.

2) handled outside control. you'll have check dialog's results , saving (e.g. write text or binary file).

just quick example (there alternative ways it). savefile control of type savefiledialog

savefiledialog savefile = new savefiledialog();  // set default file name savefile.filename = "unknown.txt"; // set filters - can done in properties savefile.filter = "text files (*.txt)|*.txt|all files (*.*)|*.*";  if (savefile.showdialog() == dialogresult.ok) {     using (streamwriter sw = new streamwriter(savefile.filename))         sw.writeline ("hello world!"); } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -