檔案正由另一個程式使用

doyouremeber發表於2009-12-07

1:    

         if (openFileDialog1.ShowDialog() == DialogResult.OK)            

            {

                                                                                                                                                                                                                                                                                               

                strFileName = openFileDialog1.FileName;

                pbxContact.Image = Image.FromFile(strFileName);

          

                try

                {

                    FileStream fs = new FileStream(strFileName, FileMode.Open,FileAccess .Read );

                    int len = Convert.ToInt32(fs.Length);

                    btPhoto = new byte[fs.Length];

                    int nByteRead = fs.Read(btPhoto, 0, len);

                    fs.Close();

                }

                catch (Exception e1)

                {

                    MessageBox.Show(e1.Message);

                }

     }

 

錯誤:if{}其作用域過大。

 

相關文章