Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

C# program that saves files with a name given in run time ?

Status
Not open for further replies.

asic1984

Full Member level 5
Full Member level 5
Joined
Nov 15, 2003
Messages
257
Helped
4
Reputation
8
Reaction score
1
Trophy points
1,298
Activity points
2,340
c# nameing files?

hi all

i need to make a program that save files with a name given in run time
which means that the file name will be variable....depend on user

how can i make this

thanks for help
 

Re: c# nameing files?

Here it is :

Code:
System.Windows.Forms.SaveFileDialog saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); 


			//show save as... file dialog			
			if(saveFileDialog1.ShowDialog()!=DialogResult.OK)return;

			//get file name from user 
			string fileName=saveFileDialog1.FileName; 

			
			FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite);

			
			try
			{
				fs.Write(....);//write data into file
			}
			catch(Exception ex)
			{
				MessageBox.Show("Error in Write File");
				
			}

			finally
			{
				
		
				fs.Close();
			}
 

Re: c# nameing files?

hi all

thank u too much for your help

but i forget to say that what i make is a console applicaion

my program take the a name of a project

then it save the filename after adding to the name some characters:

ex:

string x;
x= console.readline();
y=x+"_d";

// and now i wanna creat the file with the name y and write for it


thanks for your help even if u cannot reply
 

Re: c# nameing files?

hi all

i found the solution it is easily by putting the string variable directlt between () :roll:

sorry for losing your time but the book with me use another way which i cannot on it change the file name by entering the path :
(@"c:/...........")

and the book has very little description for i/o stream

aby way thank u too much
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top