SaveFileDIalog Bug

  • Thread starter Thread starter xucheng
  • Start date Start date
X

xucheng

When using the SaveFileDialog to overwrite an existing
file, I'm asked whether to replace the existing file.
I click the "Yes" button,System hang .

I'm using .Net Compact Framework sp2 .

my code is here.

private bool ActionSave(){
SaveFileDialog saveWav=new SaveFileDialog();
saveWav.Filter="Sounds (.wav)|*.wav|All Files|*.*";
saveWav.InitialDirectory=
OpenNETCF.EnvironmentEx.GetFolderPath(OpenNETCF.EnvironmentEx.SpecialFolder.Personal);
saveWav.FilterIndex=1;
DialogResult dl1=saveWav.ShowDialog();

if (dl1==DialogResult.OK){
if (saveWav.FileName.IndexOf(".")<0)
saveWav.FileName=saveWav.FileName+".wav";
File.Move(tmpFilename,saveWav.FileName);
return true;
}else{

return false;
}
}
 
If you have selected an existing filename, your File.Move statement will
attempt to overwrite the file, in your code following the dialog check with
File.Exists and if the file does exist delete or rename it first before
moving your file from it's temporary location.

Peter
 
But system hang at line DialogResult dl1=saveWav.ShowDialog(); you can
remove the following source code and test it it, still hang .
 
I found the reason ,

I have special code at the project beginning :

SetThreadPriority( (IntPtr)65, 1);


This line cause the SaveFileDialog can not work well.
 
Back
Top