C# compact framework: IO problem: app running on PDA can't find file.

  • Thread starter Thread starter Daniel Passwater via DotNetMonster.com
  • Start date Start date
D

Daniel Passwater via DotNetMonster.com

I've checked the file directory, and it's right. I was putting a ".txt" on the end, but someone told me that .txt is added automatically. They said that it would cause a redundancy. (i.e filename.txt.txt)

private void CheckForFile()
{
// Set directory path.
string directory = "\\My Documents\\UploadAmmoCards\\AC" +
MainOperations.AMU_SN;

// DirectoryInfo dirInfo = new DirectoryInfo(directory);

// If file does not exist
if (!File.Exists(directory))
{
MessageBox.Show(directory);
MessageBox.Show("ERROR: The file can not be found. " +
"The upload can not be processed.");
this.Close();
}

}

I have a second problem with the Close(). It gives me an ObjectDisposedException. If I handle that with a try/catch, It gives me an IO exception. Is there a reason that I can't close the form without finishing. I'm using it almost like a break.
 
I've checked the file directory, and it's right. I was putting a ".txt"
on the end, but someone told me that .txt is added automatically. They
said that it would cause a redundancy. (i.e filename.txt.txt)

private void CheckForFile()
{
// Set directory path.
string directory = "\\My Documents\\UploadAmmoCards\\AC" +
MainOperations.AMU_SN;

// DirectoryInfo dirInfo = new DirectoryInfo(directory);

// If file does not exist
if (!File.Exists(directory))
{
MessageBox.Show(directory);
MessageBox.Show("ERROR: The file can not be found. " +
"The upload can not be processed.");
this.Close();
}

}

I have a second problem with the Close(). It gives me an
ObjectDisposedException. If I handle that with a try/catch, It gives me
an IO exception. Is there a reason that I can't close the form without
finishing. I'm using it almost like a break.

Would be better posted in the
microsoft.public.dotnet.framework.compactframework group...

AFA question 2, I would ask where are you doing this check? After/at form
load, or during form construction? But I'm purely speculating here and
will leave to the other group to answer...
 
Back
Top