drillbitt
07-26-2009, 06:19 PM
Hi guys,
Im getting myself totally confused trying to replace specific variables in a .txt file.
I want to replace various parts of a txt file with session variables entered by the user.
So first I read the text file to a string:
Downloads = TextFile.ReadToString(SessionVar.Get("%AppFolder%\\downloads.txt"));
Then I get the different variables entered by the user:
YourName = SessionVar.Get("%yourname%");
WebsiteName = SessionVar.Get("%websitename%");
PayPal = SessionVar.Get("%paypalemail%");
ProductName = SessionVar.Get("%productname%");
Amount = SessionVar.Get("%amount%");
Then I use string replace, to search the Downloads string, for all occourences of ##websitename##, and to replace them with the "WebsiteName" variable.
Thewebsitename = String.Replace("Downloads", "##websitename##", "WebsiteName", false);
Is that correct, or am I way of course here? Also if I am on track, Im not sure of the proper method to re-search the new "TheWebsitename" string for all the other variables to replace? does it need to be saved first? Or is there a simpler method I could use?
Any pointers would be great!
Im getting myself totally confused trying to replace specific variables in a .txt file.
I want to replace various parts of a txt file with session variables entered by the user.
So first I read the text file to a string:
Downloads = TextFile.ReadToString(SessionVar.Get("%AppFolder%\\downloads.txt"));
Then I get the different variables entered by the user:
YourName = SessionVar.Get("%yourname%");
WebsiteName = SessionVar.Get("%websitename%");
PayPal = SessionVar.Get("%paypalemail%");
ProductName = SessionVar.Get("%productname%");
Amount = SessionVar.Get("%amount%");
Then I use string replace, to search the Downloads string, for all occourences of ##websitename##, and to replace them with the "WebsiteName" variable.
Thewebsitename = String.Replace("Downloads", "##websitename##", "WebsiteName", false);
Is that correct, or am I way of course here? Also if I am on track, Im not sure of the proper method to re-search the new "TheWebsitename" string for all the other variables to replace? does it need to be saved first? Or is there a simpler method I could use?
Any pointers would be great!