Reputation: 31
The following code works fine on Windows 7 (32-bit), but when ported to 64-bit, I get an exception stating "File Not Found". I have built the project in 64-bit configuration but the issue still persists.
The issue occurs if the machine does not have Office installed.
The code is as follows:
try
{
SaveFileDialog fileDialog = new SaveFileDialog();
fileDialog.InitialDirectory = path;
// set the default extension as mdb.
fileDialog.DefaultExt = ".mdb";
// allow the user to select the file type as CSV, XML or MDB.
fileDialog.Filter = "CSV (*.csv)|*.csv|XML (*.xml)|*.xml|MDB (*.mdb)|*.mdb";
fileDialog.RestoreDirectory = true;
if (DialogResult.OK == fileDialog.ShowDialog()) // exception occured
{
this.fileNameTextBox.Text = fileDialog.FileName;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Upvotes: 1
Views: 1164
Reputation: 2213
The question here is what's the value of "path". x86 and x64 machines may have different folder configurations, e.g. Program Files (x86) is one of them. You may start with Environment.SpecialFolders enum, those paths should be valid.
Upvotes: 1