hamedre81
یک شنبه 21 آبان 1391, 18:23 عصر
سلام
من ای کد که در متد قرار دارم کار می کنه ولی در backgroundWorker کار نمی کنه؟
این کد
defaddres = WindowsFormsApplication8.Properties.Settings.Defau lt.defaddres;
string aslas, name, defmusic;
if (Directory.Exists(defaddres) != true)
{
try
{
notifyIcon1.ShowBalloonTip(500, " ", "پوشه که آهنگ ها در آن ذخیره شوند وجود ندارند", ToolTipIcon.Error);
Directory.CreateDirectory(defaddres);
System.Threading.Thread.Sleep(1500);
notifyIcon1.ShowBalloonTip(500, " ", "پوشه که آهنگ ها در آن ذخیره شوند ساخته شد", ToolTipIcon.Info);
}
catch { }
}
if (Clipboard.ContainsFileDropList())
{
System.Collections.Specialized.StringCollection hamed = Clipboard.GetFileDropList();
foreach ( string ha in hamed)
{
if (System.IO.Path.GetExtension(ha) == ".xm" || System.IO.Path.GetExtension(ha) == ".mp2" || System.IO.Path.GetExtension(ha) == ".mp1" || System.IO.Path.GetExtension(ha) == ".aac" || System.IO.Path.GetExtension(ha) == ".ac3" || System.IO.Path.GetExtension(ha) == ".ape" || System.IO.Path.GetExtension(ha) == ".cda" || System.IO.Path.GetExtension(ha) == ".fla" || System.IO.Path.GetExtension(ha) == ".flac" || System.IO.Path.GetExtension(ha) == ".it" || System.IO.Path.GetExtension(ha) == ".kar" || System.IO.Path.GetExtension(ha) == ".m4a" || System.IO.Path.GetExtension(ha) == ".m4b" || System.IO.Path.GetExtension(ha) == ".mac" || System.IO.Path.GetExtension(ha) == ".aid" || System.IO.Path.GetExtension(ha) == ".aidi" || System.IO.Path.GetExtension(ha) == ".mo3" || System.IO.Path.GetExtension(ha) == ".mp+" || System.IO.Path.GetExtension(ha) == ".moc" || System.IO.Path.GetExtension(ha) == ".mtm" || System.IO.Path.GetExtension(ha) == ".ofr" || System.IO.Path.GetExtension(ha) == ".ofs" || System.IO.Path.GetExtension(ha) == ".oga" || System.IO.Path.GetExtension(ha) == ".wv" || System.IO.Path.GetExtension(ha) == ".rmi" || System.IO.Path.GetExtension(ha) == ".s3m" || System.IO.Path.GetExtension(ha) == ".spx" || System.IO.Path.GetExtension(ha) == ".tak" || System.IO.Path.GetExtension(ha) == ".tta" || System.IO.Path.GetExtension(ha) == ".umx" || System.IO.Path.GetExtension(ha) == ".wav" || System.IO.Path.GetExtension(ha) == ".wma" || System.IO.Path.GetExtension(ha) == ".ogg" || System.IO.Path.GetExtension(ha) == ".mp3")
{
name = System.IO.Path.GetFileName(ha);
aslas = (@"\");
defmusic = defaddres + aslas + name;
if (System.IO.File.Exists(defmusic) == true)
{
notifyIcon1.ShowBalloonTip(2000, " ", " آهنگ قبلا وجود داشته و کپی انجام نشد", ToolTipIcon.Error);
System.Media.SystemSounds.Hand.Play();
}
else
{
try
{
System.IO.File.Copy(ha, defmusic);
}
catch
{
notifyIcon1.ShowBalloonTip(2000, " ", " کپی به دلایلی انجام نشد لطفا از وجود فایل مطمئن شوید", ToolTipIcon.Error);
Clipboard.Clear();
notifyIcon1.ShowBalloonTip(2000, "دباره تلاش کنید", " دباره آهنگ مورد نظر خود را کپی کنید", ToolTipIcon.Error);
}
}
}
}
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._1;
System.Threading.Thread.Sleep(finsleep);
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._5;
System.Threading.Thread.Sleep(finsleep);
//..................
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._9;
System.Threading.Thread.Sleep(finsleep);
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._13;
System.Threading.Thread.Sleep(finsleep);
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._17;
System.Threading.Thread.Sleep(finsleep);
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._21;
System.Threading.Thread.Sleep(finsleep);
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._25;
System.Threading.Thread.Sleep(finsleep);
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._28;
System.Threading.Thread.Sleep(finsleep);
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources.icon ;
}
من اگه این کد رو داخل backgroundWorker بزارم کار نمی کنه مشکل از چیه؟
من ای کد که در متد قرار دارم کار می کنه ولی در backgroundWorker کار نمی کنه؟
این کد
defaddres = WindowsFormsApplication8.Properties.Settings.Defau lt.defaddres;
string aslas, name, defmusic;
if (Directory.Exists(defaddres) != true)
{
try
{
notifyIcon1.ShowBalloonTip(500, " ", "پوشه که آهنگ ها در آن ذخیره شوند وجود ندارند", ToolTipIcon.Error);
Directory.CreateDirectory(defaddres);
System.Threading.Thread.Sleep(1500);
notifyIcon1.ShowBalloonTip(500, " ", "پوشه که آهنگ ها در آن ذخیره شوند ساخته شد", ToolTipIcon.Info);
}
catch { }
}
if (Clipboard.ContainsFileDropList())
{
System.Collections.Specialized.StringCollection hamed = Clipboard.GetFileDropList();
foreach ( string ha in hamed)
{
if (System.IO.Path.GetExtension(ha) == ".xm" || System.IO.Path.GetExtension(ha) == ".mp2" || System.IO.Path.GetExtension(ha) == ".mp1" || System.IO.Path.GetExtension(ha) == ".aac" || System.IO.Path.GetExtension(ha) == ".ac3" || System.IO.Path.GetExtension(ha) == ".ape" || System.IO.Path.GetExtension(ha) == ".cda" || System.IO.Path.GetExtension(ha) == ".fla" || System.IO.Path.GetExtension(ha) == ".flac" || System.IO.Path.GetExtension(ha) == ".it" || System.IO.Path.GetExtension(ha) == ".kar" || System.IO.Path.GetExtension(ha) == ".m4a" || System.IO.Path.GetExtension(ha) == ".m4b" || System.IO.Path.GetExtension(ha) == ".mac" || System.IO.Path.GetExtension(ha) == ".aid" || System.IO.Path.GetExtension(ha) == ".aidi" || System.IO.Path.GetExtension(ha) == ".mo3" || System.IO.Path.GetExtension(ha) == ".mp+" || System.IO.Path.GetExtension(ha) == ".moc" || System.IO.Path.GetExtension(ha) == ".mtm" || System.IO.Path.GetExtension(ha) == ".ofr" || System.IO.Path.GetExtension(ha) == ".ofs" || System.IO.Path.GetExtension(ha) == ".oga" || System.IO.Path.GetExtension(ha) == ".wv" || System.IO.Path.GetExtension(ha) == ".rmi" || System.IO.Path.GetExtension(ha) == ".s3m" || System.IO.Path.GetExtension(ha) == ".spx" || System.IO.Path.GetExtension(ha) == ".tak" || System.IO.Path.GetExtension(ha) == ".tta" || System.IO.Path.GetExtension(ha) == ".umx" || System.IO.Path.GetExtension(ha) == ".wav" || System.IO.Path.GetExtension(ha) == ".wma" || System.IO.Path.GetExtension(ha) == ".ogg" || System.IO.Path.GetExtension(ha) == ".mp3")
{
name = System.IO.Path.GetFileName(ha);
aslas = (@"\");
defmusic = defaddres + aslas + name;
if (System.IO.File.Exists(defmusic) == true)
{
notifyIcon1.ShowBalloonTip(2000, " ", " آهنگ قبلا وجود داشته و کپی انجام نشد", ToolTipIcon.Error);
System.Media.SystemSounds.Hand.Play();
}
else
{
try
{
System.IO.File.Copy(ha, defmusic);
}
catch
{
notifyIcon1.ShowBalloonTip(2000, " ", " کپی به دلایلی انجام نشد لطفا از وجود فایل مطمئن شوید", ToolTipIcon.Error);
Clipboard.Clear();
notifyIcon1.ShowBalloonTip(2000, "دباره تلاش کنید", " دباره آهنگ مورد نظر خود را کپی کنید", ToolTipIcon.Error);
}
}
}
}
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._1;
System.Threading.Thread.Sleep(finsleep);
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._5;
System.Threading.Thread.Sleep(finsleep);
//..................
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._9;
System.Threading.Thread.Sleep(finsleep);
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._13;
System.Threading.Thread.Sleep(finsleep);
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._17;
System.Threading.Thread.Sleep(finsleep);
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._21;
System.Threading.Thread.Sleep(finsleep);
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._25;
System.Threading.Thread.Sleep(finsleep);
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources._28;
System.Threading.Thread.Sleep(finsleep);
//..................
notifyIcon1.Icon = WindowsFormsApplication8.Properties.Resources.icon ;
}
من اگه این کد رو داخل backgroundWorker بزارم کار نمی کنه مشکل از چیه؟