Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
GeneralRe: New line with streamwriter Pin
jschell17-Mar-11 10:03
jschell17-Mar-11 10:03 
GeneralRe: New line with streamwriter Pin
Pierre besquent17-Mar-11 23:11
Pierre besquent17-Mar-11 23:11 
AnswerRe: New line with streamwriter Pin
Pete O'Hanlon16-Mar-11 8:47
mvePete O'Hanlon16-Mar-11 8:47 
QuestionC# webpage playing a video from server hard drive Pin
twinscythe1233216-Mar-11 2:47
twinscythe1233216-Mar-11 2:47 
AnswerRe: C# webpage playing a video from server hard drive Pin
twinscythe1233216-Mar-11 3:15
twinscythe1233216-Mar-11 3:15 
GeneralRe: C# webpage playing a video from server hard drive Pin
Dan Mos16-Mar-11 5:47
Dan Mos16-Mar-11 5:47 
GeneralRe: C# webpage playing a video from server hard drive Pin
twinscythe1233217-Mar-11 0:59
twinscythe1233217-Mar-11 0:59 
QuestionStreamwriter output Pin
Pierre besquent15-Mar-11 21:53
Pierre besquent15-Mar-11 21:53 
Hi every body,
I wanna generate a .txt file.I use the streamwriter to write my data to a file like this:
 public static StreamWriter BuildTxtFichierVirement (ISReglementViewCollection reglements, ISISalarieCollection salaries, string myPath)
        { 
           try 
		   { 
				// Instanciation du StreamWriter avec passage du nom du fichier  
				StreamWriter		monStreamWriter = new StreamWriter(myPath, true, System.Text.Encoding.ASCII);
			    foreach (ISReglementView reglement in reglements)
				{
			    #region Date Virement  ------------------------
                string				strYear = reglement.DateReglement.Year.ToString ();
                string				strMonth = "";
                string				strDay = "";
                if (reglement.DateReglement.Month > 9)
                    strMonth = reglement.DateReglement.Month.ToString ();
                else
                    strMonth = "0" + reglement.DateReglement.Month.ToString ();
                
                if (reglement.DateReglement.Day > 9)
                    strDay = reglement.DateReglement.Day.ToString ();
                else
                    strDay = "0" + reglement.DateReglement.Day.ToString ();

                string strDate = strDay + strMonth + (strYear.ToCharArray ()) [strYear.Length - 1];

                string          date = reglement.DateReglement.Year.ToString ();
                #endregion

			    #region Entetes + EuroFranc  ------------------
                string		        strEnteteHead = "0302";
                string		        strEnteteBody = "0602";
                string		        strEnteteSum  = "0802";
                string		        strEuro     = "E";
			    string		        strFranc = "F";
                #endregion

			    #region Données RIB  --------------------------
			    string agence = "mdmff";
						string guichet = "hhlkj";
							string cle = "kjkj";
								string compte = "lkjlkj" ;
									string domicilationbancaire = "ljkjol" ;
			   
			    #endregion

				//Ecriture du texte dans votre fichier 
				monStreamWriter.WriteLine(strEnteteHead + Inserer_Espaces(8) + agence + Inserer_Espaces(7) + strDate + domicilationbancaire + reglement.ID + Inserer_Espaces(15) + strEuro + Inserer_Espaces(5) + guichet + compte + Inserer_Espaces(47) + agence + Inserer_Espaces(6)); 
				monStreamWriter.WriteLine(strEnteteBody +Inserer_Espaces(8) + agence + reglement.ID + reglement.Nom + reglement.Banque + Inserer_Espaces(12) + agence + compte + reglement.Montant + agence + Inserer_Espaces(6)); 
				monStreamWriter.WriteLine(reglement.Montant);
			    monStreamWriter.WriteLine ();
				}
// Fermeture du StreamWriter (Très important) 
			    monStreamWriter.Close(); 
			    return monStreamWriter;
          } 
		  catch (Exception exception)
            {throw ExceptionPropagation.Throw (exception, MethodBase.GetCurrentMethod ());}	
        }

saved it in a known path (C:\Documents and Settings\My Documents\Visual Studio 2008myprojects\MyFile.txt). I want now to let the user choose where he wants to save his txt File.
How can I import the data from my txt File to copy them in the specified file choosen by the user of my application????
Thank u very much
AnswerRe: Streamwriter output Pin
Mycroft Holmes15-Mar-11 22:18
professionalMycroft Holmes15-Mar-11 22:18 
GeneralRe: Streamwriter output Pin
Pierre besquent15-Mar-11 22:51
Pierre besquent15-Mar-11 22:51 
GeneralRe: Streamwriter output Pin
Pete O'Hanlon15-Mar-11 23:05
mvePete O'Hanlon15-Mar-11 23:05 
GeneralRe: Streamwriter output Pin
Pierre besquent15-Mar-11 23:10
Pierre besquent15-Mar-11 23:10 
GeneralRe: Streamwriter output Pin
Pete O'Hanlon15-Mar-11 23:31
mvePete O'Hanlon15-Mar-11 23:31 
GeneralRe: Streamwriter output Pin
Pierre besquent16-Mar-11 0:52
Pierre besquent16-Mar-11 0:52 
AnswerRe: Streamwriter output Pin
Richard MacCutchan15-Mar-11 23:12
mveRichard MacCutchan15-Mar-11 23:12 
GeneralRe: Streamwriter output Pin
Pierre besquent15-Mar-11 23:23
Pierre besquent15-Mar-11 23:23 
GeneralRe: Streamwriter output Pin
Richard MacCutchan15-Mar-11 23:42
mveRichard MacCutchan15-Mar-11 23:42 
GeneralRe: Streamwriter output Pin
Pete O'Hanlon15-Mar-11 23:48
mvePete O'Hanlon15-Mar-11 23:48 
GeneralRe: Streamwriter output Pin
Pierre besquent16-Mar-11 0:09
Pierre besquent16-Mar-11 0:09 
AnswerRe: Streamwriter output Pin
Luc Pattyn16-Mar-11 0:06
sitebuilderLuc Pattyn16-Mar-11 0:06 
GeneralRe: Streamwriter output Pin
Pierre besquent16-Mar-11 0:11
Pierre besquent16-Mar-11 0:11 
GeneralRe: Streamwriter output Pin
Pete O'Hanlon16-Mar-11 0:23
mvePete O'Hanlon16-Mar-11 0:23 
GeneralRe: Streamwriter output Pin
Luc Pattyn16-Mar-11 0:27
sitebuilderLuc Pattyn16-Mar-11 0:27 
GeneralRe: Streamwriter output Pin
Pierre besquent16-Mar-11 3:41
Pierre besquent16-Mar-11 3:41 
Questionbest data strcuture for numeric parsing. Pin
shivamkalra15-Mar-11 18:24
shivamkalra15-Mar-11 18:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.