Hi All,
I have an interesting problem, I need to create save files in the following format SV_XXXX.msg in a specified location. This I am doing I have a folder with SV_0000.msg to SV_0132.msg
however it will not create SV_0133.msg onwards, it just appears to over write SV_0132.msg with the last data. Is there a reason for this or do I have to rework the way I am calculating the number?
Glenn
Loading
VulpesPosted Aug 29, 2012, 9:40 AM
Glenn PattonPosted Aug 29, 2012, 9:49 AM
Glenn PattonPosted Aug 29, 2012, 9:28 AM
if(string[] file_Next = Directory.GetFiles(@mydocpath, "*.msg") == Null)
{
file_Next = SV_0000.msg;
/* or null to avoid there never being a 0000 */
}
followed by
string[] file_Next = Directory.GetFiles(@mydocpath, "SV_????.msg");
However this problem aside it appears to have cured the issue (at the moment)
Glenn
Glenn PattonPosted Aug 29, 2012, 8:09 AM
VulpesPosted Aug 29, 2012, 8:04 AM
I'd try placing this line immediately after the LINQ code:
FileCounter++;
Glenn PattonPosted Aug 29, 2012, 7:52 AM
sw.WriteLine(Unit_Reply_Modded);
FileCounter++;
strFileCount = Convert.ToString(FileCounter); ;
sw.Close();
As this is in a click routine might it not being seen/skipping it?
VulpesPosted Aug 29, 2012, 7:29 AM
If this is happening with the next file to be saved after retrieving the maximum existing file, have you remembered to increase FileCounter by one?
Glenn PattonPosted Aug 29, 2012, 7:08 AM
-=-=-=-=-=-=-=-=-=-=-=-=-
This seems to have righted it self
VulpesPosted Aug 29, 2012, 7:05 AM
Glenn PattonPosted Aug 29, 2012, 6:44 AM
VulpesPosted Aug 29, 2012, 6:32 AM
Glenn PattonPosted Aug 29, 2012, 6:26 AM
VulpesPosted Aug 29, 2012, 6:22 AM
Glenn PattonPosted Aug 29, 2012, 6:02 AM
Glenn
VulpesPosted Aug 29, 2012, 5:37 AM
If there are any other files (not fitting your pattern) which have a .msg extension, then they may be being counted.
If there are omissions in the sequence of files fitting your pattern (say sv_0130 is missing), then this will also mess up the counting.
So how are you calculating FileCounter?
If you're just using file_Next.Length, then this might be causing the problem.
Glenn PattonPosted Aug 29, 2012, 5:29 AM
string[] file_Next = Directory.GetFiles(@mydocpath, "*.msg");
int FileTotal = 0;
and once the file data has been set up
StreamWriter sw = new StreamWriter(mydocpath + @"\SV_" + FileNameRecord + ".msg");
dt.ToString("yyyy/MM/dd HH:mm:ss");
FileNameRecord = (FileIDFiller + FileCounter.ToString());
//StreamWriter sw = new StreamWriter(mydocpath + @"\SV_" + FileNameRecord + ".msg");
sw.WriteLine("Test " + FileCounter.ToString()+" "+dt.ToString());
sw.WriteLine(Unit_Reply_Modded);
FileCounter++;
strFileCount = Convert.ToString(FileCounter); ;
sw.Close();
Could something here be causing the problem....
Glenn
VulpesPosted Aug 29, 2012, 5:17 AM
Glenn PattonPosted Aug 29, 2012, 4:36 AM
Glenn
Glenn PattonPosted Aug 28, 2012, 11:51 AM
Yup my code is causing the problem (suprise, suprise).
VulpesPosted Aug 28, 2012, 11:31 AM
copy con SV_0216.msg
^Z
To type ^Z, press the Z key while holding down the Ctrl key.
If that succeeds in creating an empty file, then you'll know that the problem lies with your code rather than the OS.
Glenn PattonPosted Aug 28, 2012, 11:03 AM
Glenn
VulpesPosted Aug 28, 2012, 10:31 AM
Years ago, there used to be a limit on the number of files you could have in a root drive under Windows. I'm not sure whether there's a limit now or not, but even if there is I'm sure the OS wouldn't just overwrite an existing file.
Glenn PattonPosted Aug 28, 2012, 10:02 AM
Glenn PattonPosted Aug 28, 2012, 10:02 AM
EDIT
=-=-=-=-=-=-=-=-=-=-=-=-=
It seems it is not a problem other than the directory it is supposed to be!!!
Suthish NairPosted Aug 28, 2012, 9:53 AM