|
My guess is a typo in your code when it comes to the filename. If you choose the file to have a ".txt" extension i doubt anything in .NET makes it ".pxp" instead..
|
|
|
|
|
Try
string date = DateTime.Now.ToString("yyyyMMdd_hhmmss");
TextWriter tw = new StreamWriter(string.Format("{0}.txt", date));
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Thanks for such a hasty reply
I've tried your code:
string date = DateTime.Now.ToString("yyyyMMdd_hhmmss");
TextWriter tw = new StreamWriter(string.Format("{0}.txt", date));
And in the editor (visual express) it underlines the 'date' in string.Format("{0}.txt", date) in red, with an error message below.
I warn you again, i am very green at C# :s
|
|
|
|
|
What's the error message?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
"A field initializer cannot reference the non-static field, method, or property"
|
|
|
|
|
Copy and paste your code - you have a spelling or wrong bracket error somewhere. The compiler seems to think your string is not a string! Not all of it! Just the relevant method or a section around the code!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
No need, it was indeed just a wrong bracket error, which i noticed once you suggested it.
Sods Law.
The code you gave me works perfectly
Very much appreciated
|
|
|
|
|
string fileName = DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt";
fileName = Application.StartupPath + "\\" + fileName;
StreamWriter sw = new StreamWriter(fileName);
sw.WriteLine("Some Data");
sw.Close();
...hope this helps you
EDIT: Error with code block formatting???
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
musefan wrote: Error with code block formatting???
Could it be that the colourer ignores the \\ and therefore sees a \" which means the string isn't closed?
|
|
|
|
|
Yeah, I assume it just does a last character check and does not check the \ if that is the last character
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Thanks
Seems to function exactly how i was wanting it to
Very much appreciated
|
|
|
|
|
Yeah, the "t" in the format is interpreted as a request for "am" or "pm" as appropriate; so in the afternoon, you get "pxp", in the morning you'd get "axa".
In the future you could try "yyyyMMdd_hhmmss.'txt'" .
Oh, and use HH to get 24-hour time.
modified on Thursday, August 27, 2009 3:19 PM
|
|
|
|
|
Ahhhh, thankyou.
All seems much clearer now.
Thanks for the extra tip too
|
|
|
|
|
|
hi guys
i have a grid in whihc i have two columns these are check box columns
now i want to iterate all the rows of grid and to perform some action but only if one of the two check box columns is active or checked else i am skipping the current row
i am doing the floowing but it is not working correctly
(!(Convert.ToBoolean(ugrRow.Cells["Add to device "].Value)) && Convert.ToBoolean(ugrRow.Cells["Discard"].Value)))
continue;
else
{perform logic here .}
Tauseef A Khan
MCP Dotnet framework 2.0.
|
|
|
|
|
try this...
if((bool)ugrRow.Cells["Add to device "].Value || (bool)ugrRow.Cells["Disgard"].Value)
{
}
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
How to pass apostrophe to .Trim() Method ?
It is working
sValues.Trim(',')
But here is problem
sValues.Trim(''')
|
|
|
|
|
|
hii...
i enter value in textbox which is number eg:1001
now i want to convert this into string.like:
one thousand and one.
how can i do it using csharp...
reply....
|
|
|
|
|
easy...
int number = 1001;
switch(number)
{
case 0:
return "zero";
case 1:
return "one";
case 1001:
return "one thousand and one";
}
... No, I'm joking. But not far off, have a look at this[^]
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
http://www.blackwasp.co.uk/NumberToWords.aspx
Please refer this site easy for you.
|
|
|
|
|
Very useful, I'll keep it in mind if I ever need to use it
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Ah, so you get paid by the number of lines of code...
|
|
|
|
|
I wish, because then I would be intentionally making the most inefficient programs ever!
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
That's a homework problem that shows up here many times at this time of year; you can search.
|
|
|
|