C# Make application compatible on other computers? -
edit: here file if want test: cleaner
i'm making program cleans files automatically @ startup performance reasons.
how make application work on computer has release files?
i made application using framework 2.0 , works correctly without errors on computer if copy release files computer, "application stopped responding" happens when starts.
there no resource files except icon , embedded resource. have no idea do.
private void cleansystem() { timer1.enabled = true; timer1.start(); progressbar1.maximum = 10; string offline = environment.expandenvironmentvariables("%systemroot%") + "\\offline web pages"; string download = environment.expandenvironmentvariables("%systemroot%") + "\\downloaded program files"; string software = environment.expandenvironmentvariables("%systemroot%") + "\\softwaredistribution\\download"; string wintemp = environment.expandenvironmentvariables("%systemroot%") + "\\temp"; string recent = environment.expandenvironmentvariables("%appdata%") + "\\microsoft\\windows\\recent"; string cookies = environment.expandenvironmentvariables("%appdata%") + "\\microsoft\\windows\\cookies"; string tempinternet = environment.expandenvironmentvariables("%userprofile%") + "\\local settings\\temporary internet files"; string apptemp = environment.expandenvironmentvariables("%userprofile%") + "\\appdata\\local\\temp"; string settingtemp = environment.expandenvironmentvariables("%userprofile%") + "\\local settings\\temp"; emptyfoldercontents(offline); emptyfoldercontents(download); emptyfoldercontents(software); emptyfoldercontents(wintemp); emptyfoldercontents(recent); emptyfoldercontents(cookies); emptyfoldercontents(tempinternet); emptyfoldercontents(apptemp); emptyfoldercontents(settingtemp); timer1.interval = 1000; timer1.tick += new eventhandler(timer1_tick); } private void emptyfoldercontents(string foldername) { foreach (var folder in directory.getdirectories(foldername)) { try { directory.delete(folder, true); } catch (exception excep) { logger.fatal(excep); } } foreach (var file in directory.getfiles(foldername)) { try { file.delete(file); } catch (exception excep) { logger.fatal(excep); } } } void timer1_tick(object sender, eventargs e) { if (progressbar1.value != 10) { progressbar1.value++; } else { environment.exit(0); } } }
}
2013-05-08 18:02:58.7013 fatal system.io.ioexception: process cannot access file 'c:\windows\temp\cleaner.vsho_130508_173905_05efe1ff-6b41-4cb6-bb00-7acad6960c36.itrace' because being used process. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath)
@ system.io.file.internaldelete(string path, boolean checkhost) @ system.io.file.delete(string path) @ gifimagee.mainwindow.emptyfoldercontents(string foldername) in c:\users\administrator\documents\visual studio 2012\projects\tet\cleaner\cleaner\mainwindow.xaml.cs:line 923 2013-05-08 18:02:58.7349 fatal system.io.ioexception: process cannot access file 'c:\windows\temp\oso.vshost.exe_130508_174608_0d66d9df-040c-457b-84b5-7c3576196718.itrace' because being used process. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath)
@ system.io.file.internaldelete(string path, boolean checkhost) @ system.io.file.delete(string path) @ gifimagee.mainwindow.emptyfoldercontents(string foldername) in c:\users\administrator\documents\visual studio 2012\projects\tet\cleaner\cleaner\mainwindow.xaml.cs:line 923 2013-05-08 18:02:58.8630 fatal system.unauthorizedaccessexception: access path 'aug2005_d3dx9_27_x64.cab' denied. @ system.io.directory.deletehelper(string fullpath, string userpath, boolean recursive, boolean throwontopleveldirectorynotfound) @ system.io.directory.delete(string fullpath, string userpath, boolean recursive, boolean checkhost) @ system.io.directory.delete(string path, boolean recursive) @ gifimagee.mainwindow.emptyfoldercontents(string foldername) in c:\users\administrator\documents\visual studio 2012\projects\tet\cleaner\cleaner\mainwindow.xaml.cs:line 912 2013-05-08 18:02:58.8743 fatal system.io.ioexception: process cannot access file 'c:\users\administrator\appdata\local\temp\etilqs_2isw34p5elyyp6d' because being used process. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath)
@ system.io.file.internaldelete(string path, boolean checkhost) @ system.io.file.delete(string path) @ gifimagee.mainwindow.emptyfoldercontents(string foldername) in c:\users\administrator\documents\visual studio 2012\projects\tet\cleaner\cleaner\mainwindow.xaml.cs:line 923 2013-05-08 18:02:58.9074 fatal system.io.ioexception: process cannot access file 'c:\users\administrator\appdata\local\temp\etilqs_7cswlodfr5gbuud' because being used process. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath)
@ system.io.file.internaldelete(string path, boolean checkhost) @ system.io.file.delete(string path) @ gifimagee.mainwindow.emptyfoldercontents(string foldername) in c:\users\administrator\documents\visual studio 2012\projects\tet\cleaner\cleaner\mainwindow.xaml.cs:line 923 2013-05-08 18:02:58.9279 fatal system.io.ioexception: process cannot access file 'c:\users\administrator\appdata\local\temp\etilqs_9htgcbvueeppsk3' because being used process. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath)
@ system.io.file.internaldelete(string path, boolean checkhost) @ system.io.file.delete(string path) @ gifimagee.mainwindow.emptyfoldercontents(string foldername) in c:\users\administrator\documents\visual studio 2012\projects\tet\cleaner\cleaner\mainwindow.xaml.cs:line 923 2013-05-08 18:02:58.9389 fatal system.io.ioexception: process cannot access file 'c:\users\administrator\appdata\local\temp\etilqs_fpoiwpujdlckgey' because being used process. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath)
@ system.io.file.internaldelete(string path, boolean checkhost) @ system.io.file.delete(string path) @ gifimagee.mainwindow.emptyfoldercontents(string foldername) in c:\users\administrator\documents\visual studio 2012\projects\tet\cleaner\cleaner\mainwindow.xaml.cs:line 923 2013-05-08 18:02:58.9703 fatal system.io.ioexception: process cannot access file 'c:\users\administrator\appdata\local\temp\etilqs_jtj95qhtnu6vj7d' because being used process. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath)
@ system.io.file.internaldelete(string path, boolean checkhost) @ system.io.file.delete(string path) @ gifimagee.mainwindow.emptyfoldercontents(string foldername) in c:\users\administrator\documents\visual studio 2012\projects\tet\cleaner\cleaner\mainwindow.xaml.cs:line 923 2013-05-08 18:02:59.0947 fatal system.unauthorizedaccessexception: access path 'aug2005_d3dx9_27_x64.cab' denied. @ system.io.directory.deletehelper(string fullpath, string userpath, boolean recursive, boolean throwontopleveldirectorynotfound) @ system.io.directory.delete(string fullpath, string userpath, boolean recursive, boolean checkhost) @ system.io.directory.delete(string path, boolean recursive) @ gifimagee.mainwindow.emptyfoldercontents(string foldername) in c:\users\administrator\documents\visual studio 2012\projects\tet\cleaner\cleaner\mainwindow.xaml.cs:line 912 2013-05-08 18:02:59.1152 fatal system.io.ioexception: process cannot access file 'c:\users\administrator\local settings\temp\etilqs_2isw34p5elyyp6d' because being used process. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath) @ system.io.file.internaldelete(string path, boolean checkhost) @ system.io.file.delete(string path) @ gifimagee.mainwindow.emptyfoldercontents(string foldername) in c:\users\administrator\documents\visual studio 2012\projects\tet\cleaner\cleaner\mainwindow.xaml.cs:line 923 2013-05-08 18:02:59.1263 fatal system.io.ioexception: process cannot access file 'c:\users\administrator\local settings\temp\etilqs_7cswlodfr5gbuud' because being used process. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath) @ system.io.file.internaldelete(string path, boolean checkhost) @ system.io.file.delete(string path) @ gifimagee.mainwindow.emptyfoldercontents(string foldername) in c:\users\administrator\documents\visual studio 2012\projects\tet\cleaner\cleaner\mainwindow.xaml.cs:line 923 2013-05-08 18:02:59.1563 fatal system.io.ioexception: process cannot access file 'c:\users\administrator\local settings\temp\etilqs_9htgcbvueeppsk3' because being used process. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath) @ system.io.file.internaldelete(string path, boolean checkhost) @ system.io.file.delete(string path) @ gifimagee.mainwindow.emptyfoldercontents(string foldername) in c:\users\administrator\documents\visual studio 2012\projects\tet\cleaner\cleaner\mainwindow.xaml.cs:line 923 2013-05-08 18:02:59.1774 fatal system.io.ioexception: process cannot access file 'c:\users\administrator\local settings\temp\etilqs_fpoiwpujdlckgey' because being used process. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath) @ system.io.file.internaldelete(string path, boolean checkhost) @ system.io.file.delete(string path) @ gifimagee.mainwindow.emptyfoldercontents(string foldername) in c:\users\administrator\documents\visual studio 2012\projects\tet\cleaner\cleaner\mainwindow.xaml.cs:line 923 2013-05-08 18:02:59.1886 fatal system.io.ioexception: process cannot access file 'c:\users\administrator\local settings\temp\etilqs_jtj95qhtnu6vj7d' because being used process. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath) @ system.io.file.internaldelete(string path, boolean checkhost) @ system.io.file.delete(string path) @ gifimagee.mainwindow.emptyfoldercontents(string foldername) in c:\users\administrator\documents\visual studio 2012\projects\tet\cleaner\cleaner\mainwindow.xaml.cs:line 923
i try change code in way
private void emptyfoldercontents(string foldername) { if(directory.exists(foldername) { foreach (var folder in directory.getdirectories(foldername)) { try { directory.delete(folder, true); } catch(exception ex) { messagebox.show("error deleting folder: " + folder+ environment.newline + ex.message); } } foreach (var file in directory.getfiles(foldername)) { try { file.delete(file); } catch(exception ex) { messagebox.show("error deleting file: " + file + environment.newline + ex.message); } } }
}
i have added minimal check see if directory exists, keep in mind code fail large number of reasons. look @ exceptions list on msdn documentation
Comments
Post a Comment