D
dubiousp
Guest
Evening all,, the last part of my code below saves the file by an increment of 1.. Im struggling to work out how to check for the last save number so I would like it save last number in dir was 10 the next would be 11 irrellevent of starting and stopping the app
private static int iCount = 0;
private void btnSave_Click(object sender, EventArgs e)
{
// Strings used to format text write
string sp = " ";
string ost = (tbonscene.Text);
string con = (cbconsent.Text);
string avpu = (cbavpu.Text);
string fn = (tBFIRSTNAME.Text);
string sn = (tBSURNAME.Text);
string dob = (dtpdob.Text);
string age = (tbage.Text);
string gen = (cbgender.Text);
string incnum = (lblincnum.Text);
// Check for directory setup, if setup then ignore or create directory on desktop
string dir = (@"c:\PRF");
bool exists = System.IO.Directory.Exists(dir);
if (!exists)
System.IO.Directory.CreateDirectory(dir);
// Check for file name if does not exist create, this is to be an increment of incident number
string id = lblincnum.Text;
string path = @"c:\\PRF\\" + id +".txt";
StreamWriter File = new StreamWriter(path);
File.Write(ost);
File.Close();
//Increment incident number by one on save
iCount = iCount + 1;
lblincnum.Text = iCount.ToString();
Continue reading...
private static int iCount = 0;
private void btnSave_Click(object sender, EventArgs e)
{
// Strings used to format text write
string sp = " ";
string ost = (tbonscene.Text);
string con = (cbconsent.Text);
string avpu = (cbavpu.Text);
string fn = (tBFIRSTNAME.Text);
string sn = (tBSURNAME.Text);
string dob = (dtpdob.Text);
string age = (tbage.Text);
string gen = (cbgender.Text);
string incnum = (lblincnum.Text);
// Check for directory setup, if setup then ignore or create directory on desktop
string dir = (@"c:\PRF");
bool exists = System.IO.Directory.Exists(dir);
if (!exists)
System.IO.Directory.CreateDirectory(dir);
// Check for file name if does not exist create, this is to be an increment of incident number
string id = lblincnum.Text;
string path = @"c:\\PRF\\" + id +".txt";
StreamWriter File = new StreamWriter(path);
File.Write(ost);
File.Close();
//Increment incident number by one on save
iCount = iCount + 1;
lblincnum.Text = iCount.ToString();
Continue reading...