VB.NET - Access to path %appdata% is denied -


i making mod installer minecraft community, when ended problem:

error description

here's code:

    private sub button1_click(sender object, e eventargs) handles button1.click              button1.enabled = false             button2.enabled = false             combobox1.enabled = false             button1.text = "downloading... not quit!"        dim selected string     dim issel boolean     issel = false     selected = combobox1.selecteditem     if selected = "minecade mod 1.7.2"         selected = "5"         issel = true     end if     if selected = "minecade mod 1.7.2 optifine standard"         selected = "3"         issel = true     end if     if selected = "minecade mod 1.7.2 optifine ultra"         selected = "4"         issel = true     end if     if selected = "minecade mod 1.7.2 optifine standard , minecade capes"         selected = "1"         issel = true     end if     if selected = "minecade mod 1.7.2 optifine ultra , minecade capes"         selected = "2"         issel = true     end if      if issel = false         msgbox("invalid selection! try again.")      else         dim answ integer         answ = msgbox("you have chosen mod id of: " & selected & "." & vbcrlf & "do want install mod?", vbyesno)         if answ = 6              if my.computer.filesystem.fileexists("c:\documents , settings\all users\documents\jowd\minecademod\1.7.2modded" & selected & ".zip")                 dim answoverw integer = msgbox("the file exists on download location. wish download file again (no) or want continue old 1 (yes)? (preferred: yes)", vbyesno)                 '6y7n               end if               'installation process begins               try                 dim dlpath string = environment.getfolderpath(environment.specialfolder.mydocuments) & "jowd\minecademod\1.7.2modded" & selected & ".zip"                 my.computer.network.downloadfile("http://files.casualnetwork.net/installers/moddedminec/1.7.2modded" & selected & ".zip", dlpath, "", "", false, 500, true)                 dim unpackandinstall boolean = msgbox("download succesful. want unpack , install archieve?", vbyesno)                 if unpackandinstall = true                     'unpack ------- 

'''error occures inside try tags here!'''

                    try                          dim filepath string                         filepath = environment.getfolderpath(environment.specialfolder.applicationdata) & ".minecraft\versions\1.7.2modded" & selected                         dim startpath string = environment.getfolderpath(environment.specialfolder.mydocuments) & "jowd\minecademod\1.7.2modded" & selected & ".zip"                         dim zippath string = filepath                         dim extractpath string = filepath                          my.computer.filesystem.createdirectory(filepath)                          zipfile.createfromdirectory(startpath, zippath)                          zipfile.extracttodirectory(zippath, extractpath)                         msgbox("decompression, installation , finishing done! ready play!")                     catch ex exception                          msgbox("error in decompression , installment proceidure." & vbcrlf & vbcrlf & ex.message & vbcrlf & vbcrlf & "report jowd, should not happen!")                         button1.enabled = true                         button2.enabled = true                         combobox1.enabled = true                         button1.text = "download , install!"                      end try 

'''error area ends!'''

                end if             catch ex exception                 button1.enabled = true                 button2.enabled = true                 combobox1.enabled = true                 button1.text = "download , install!"                 msgbox("download failed. error code below!" & vbcrlf & vbcrlf & ex.message & vbcrlf & vbcrlf & "check main topic possible solution, if nothing applies leave reply!")                 exit sub             end try           else             'installation process aborted.           end if     end if  end sub 

i happy answer question related problem, i've tried anywhere nothing helps me!

thanks.


read! edited.

regarding 2 answers david sdot , visual vincent, - answers did not fix problem.

i tried use following line on code:

filepath = environment.getfolderpath(environment.specialfolder.applicationdata) & "\.minecraft\versions\1.7.2modded" & selected 

same error occurred.

still looking more advices you!

leave comment if want project file test out.


read! edited.

here's source app, testing there!

http://files.casualnetwork.net/installers/moddedminec/source/minecademodinstaller_min.zip

ok here's solution problem:

here, used webclient instead of my.computer.network.downloadfile, since think it's better. (you use whatever want of course)

dim download new webclient download.downloadfileasync(new uri("http://files.casualnetwork.net/installers/moddedminec/1.7.2modded" & selected & ".zip"), dlpath) 

i noticed stuff had changed in code. reason tried zip file itself:

zipfile.createfromdirectory(startpath, zippath) 

remove this. :)


and tried extract .minecraft\versions\1.7.2modded doing this:

    dim startpath string = environment.getfolderpath(environment.specialfolder.mydocuments) & "\jowd\minecademod\1.7.2modded" & selected & ".zip"     dim zippath string = filepath     dim extractpath string = filepath      zipfile.extracttodirectory(zippath, extractpath) 

simply change zippath from:

dim zippath string = filepath 

to:

dim zippath string = startpath 

now zipping should work fine :)


one more thing noticed couldn't skip unzip part if pressed "no" in msbox. changed code little:

dim unpackandinstall dialogresult unpackandinstall = messagebox.show("download succesful. want unpack , install archieve?", "", messageboxbuttons.yesno) if unpackandinstall = windows.forms.dialogresult.yes     ... end if 

here's whole try block:

        try             dim download new webclient             dim dlpath string = environment.getfolderpath(environment.specialfolder.mydocuments) & "\jowd\minecademod\1.7.2modded" & selected & ".zip"             download.downloadfileasync(new uri("http://files.casualnetwork.net/installers/moddedminec/1.7.2modded" & selected & ".zip"), dlpath)              dim unpackandinstall dialogresult             unpackandinstall = messagebox.show("download succesful. want unpack , install archieve?", "", messageboxbuttons.yesno)             if unpackandinstall = windows.forms.dialogresult.yes                  try                      dim filepath string                     filepath = environment.getfolderpath(environment.specialfolder.applicationdata) & "\.minecraft\versions\1.7.2modded" & selected                     dim startpath string = environment.getfolderpath(environment.specialfolder.mydocuments) & "\jowd\minecademod\1.7.2modded" & selected & ".zip"                     dim zippath string = startpath                     dim extractpath string = filepath                      my.computer.filesystem.createdirectory(filepath)                      'zipfile.createfromdirectory(startpath, zippath)                      zipfile.extracttodirectory(zippath, extractpath)                     msgbox("decompression, installation , finishing done! ready play!")                 catch ex exception                      msgbox("error in decompression , installment proceidure." & vbcrlf & vbcrlf & ex.message & vbcrlf & vbcrlf & "report jowd, should not happen!")                     button1.enabled = true                     button2.enabled = true                     combobox1.enabled = true                     button1.text = "download , install!"                  end try              end if         catch ex exception             button1.enabled = true             button2.enabled = true             combobox1.enabled = true             button1.text = "download , install!"             msgbox("download failed. error code below!" & vbcrlf & vbcrlf & ex.message & vbcrlf & vbcrlf & "check main topic possible solution, if nothing applies leave reply!")             exit sub         end try 

and replace

download.downloadfileasync(new uri("http://files.casualnetwork.net/installers/moddedminec/1.7.2modded" & selected & ".zip"), dlpath) 

with my.computer.network code if you'd rather use instead. :)

hope helps!


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -