Click here to Skip to main content
13,042,421 members (137,657 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all,
I would like to save a text file the same name as the original file I open using the open file dialog.
I use open file dialog and have

ArrayList fileList = new ArrayList;
foreach(string file in fileList)  //where file =C:\Users\Iman\Desktop\Thermo  Data\gygi_vp_0014.mgf
    //do stuff
    //and write to text with original filename "gygi_vp0014.mgf" + "modified"
    streamwriter sw = new streamwriter( what do I put here")

Thanks in advance!
Posted 28-Apr-11 10:05am
Updated 28-Apr-11 10:19am
PasanRatnayake 29-Apr-11 0:25am
You want to open a file "aaaaaa.mgf", edit it, write the contents to a text file with the name "aaaaaa.mgf modified.txt"? Is it?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

One of the simplest ways to write to a text file is to use File.WriteAllText.

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

using (StreamWriter writer= new StreamWriter("test.txt"))
     while(true); // note, it fills the disk up very quickly.
         writer.WriteLine("test StreamWriter");

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 28 Apr 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100