CrookDawg Posted September 24, 2004 Posted September 24, 2004 the answer is probabaly posted everywhere but i cant seem to find the answer. anyway heres the problem: this is in visual basic .net not asp or anything else just plain old visual basic .net. when i try to write a file to a directory that the user selects, i get an this access denied error: An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll Additional information: Access to the path "C:\Documents and Settings\Matt\Desktop" is denied. i have tried to use permissions sets but i can't figure out how. :mad: that said i have another problem totally unrelated but i can't figure that out either: on all the programs that i make i use the Application.EnableVisualStyles() routine in the first form of the program. now on some programs this does not carry over to additional forms, however, on some programs it does. i cant figure it out. thanks in advance -matt Quote
CrookDawg Posted September 27, 2004 Author Posted September 27, 2004 anybody ever had this problem?... Quote
Administrators PlausiblyDamp Posted September 28, 2004 Administrators Posted September 28, 2004 Does the user running the applicaion have access to that folder? What are you trying to do with the folder - any chance of posting some of your code? Where are you running the application from? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
TripleB Posted September 28, 2004 Posted September 28, 2004 User Account With Password Hey, it could be that the account you are trying to acces is made personal so you don't have rights to read or write to that folder. you can change the permissions on that account so that you can acces them... Greetz Quote
CrookDawg Posted September 29, 2004 Author Posted September 29, 2004 ill work on what you said but for now im getting some odd errors that i can't seem to figure out what is causing them. things like when i use showdialog to show a form, and then use the me.close() method on the form, i get an error. this is what it tells me: An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in system.windows.forms.dll Additional information: External component has thrown an exception. i belive that i have used this before but it doesn't work for some reason now. im having another problem if anybody can help me out. i have a c1zipfile declared public in a module. when i open the file, i say zip = new c1zipfile then zip.open(filename). now, whenever i go to extract, i get a "Object reference not set to an instance of an object" error. nowhere in the code does it change the zip entry to nothing. this is the main reason that i can't test the your suggestions. does anyone know what happened to my visual styles on my second form cause i can't seem to get them back. im working on that now...and oh yea i just got hit by the hurricane again :rolleyes: i know this is a mouthful and im relatively new to vb so thanks for the responses and ill get back you you once i get this error figured out. Quote
TripleB Posted September 30, 2004 Posted September 30, 2004 ill work on what you said but for now im getting some odd errors that i can't seem to figure out what is causing them. things like when i use showdialog to show a form, and then use the me.close() method on the form, i get an error. this is what it tells me: An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in system.windows.forms.dll Additional information: External component has thrown an exception. i belive that i have used this before but it doesn't work for some reason now. im having another problem if anybody can help me out. i have a c1zipfile declared public in a module. when i open the file, i say zip = new c1zipfile then zip.open(filename). now, whenever i go to extract, i get a "Object reference not set to an instance of an object" error. nowhere in the code does it change the zip entry to nothing. this is the main reason that i can't test the your suggestions. does anyone know what happened to my visual styles on my second form cause i can't seem to get them back. im working on that now...and oh yea i just got hit by the hurricane again :rolleyes: i know this is a mouthful and im relatively new to vb so thanks for the responses and ill get back you you once i get this error figured out. Hey, do you try to use the extract method from another form or something because if you do you don't have acces to it, if not could you give some code so that we can see what you are trying to do? greetz Quote
CrookDawg Posted September 30, 2004 Author Posted September 30, 2004 they were not in the same code. the declaration was public in a module and the extraction was in a form. i moved the extract code into the module (slightly modified) and ran it and it gave me the same error. however i did try adding zip to the watch and it game me the following error: cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class. i think i fixed this by delcaring an instance of the class. i feel stupid :rolleyes: im still getting an error that says object reference not set to an instance of an object and this is driving me crazy becuase i can't figure out where it sets zip to nothing. in the watch window it says "nothing" and never goes to anything except when stepping though the open sub that i declared. after that it just goes to nothing. This is my declaration in the module. Public Zip As C1ZipFile Public Extract as New Extract Public Class Extract Public Shared Sub ExtractAll(ByVal lstFiles As ListView, ByVal ExtractPath As String) Dim lvi As ListViewItem Dim ze As C1.C1Zip.C1ZipEntry For Each lvi In lstFiles.Items ze = lvi.Tag Zip.Entries.Extract(lvi.Index, ExtractPath) 'Declarations.Zip.Entries.Extract(lvi.Index, txtPath.Text) Next End Sub End Class Thanks for all your help -matt Quote
CrookDawg Posted October 4, 2004 Author Posted October 4, 2004 anybody...? your help is greatly appreciated :-\ Quote
Administrators PlausiblyDamp Posted October 4, 2004 Administrators Posted October 4, 2004 Which line of the code throws the error? When you step through the code is the zip object always nothing? If not where are you assigning a value to it? Are you still getting the original access denied error or have things changed since then? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
CrookDawg Posted October 5, 2004 Author Posted October 5, 2004 Which line of the code throws the error? When you step through the code is the zip object always nothing? If not where are you assigning a value to it? Are you still getting the original access denied error or have things changed since then? Thanks for the reply, the line that throws the error is: Zip.Entries.Extract(lvi.Index, ExtractPath) this is the error An unhandled exception of type 'System.NullReferenceException' occurred in FreeZip.exe Additional information: Object reference not set to an instance of an object. when i step through the code, it only shows the delcaration (public dim Zip as c1zipfile) and not the value, however when im in the sub that open the zip file (zip.open) the value changes to what i want. after i leave the sub zip returns to the declaration statement. im assigining the value in a sub in a module and it works fine but ONLY in that sub. as of right now i am not getting the access denied error because i get this error first. after i fix this one i assume then i have to fix the access denied error :rolleyes: Thanks for your help -matt Quote
Administrators PlausiblyDamp Posted October 5, 2004 Administrators Posted October 5, 2004 Could you post the code for the sub where this works / zip has a value? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
CrookDawg Posted October 6, 2004 Author Posted October 6, 2004 Could you post the code for the sub where this works / zip has a value? here is the code right after this the value changes to nothing Public Sub Open() Dim dlgOpen As New OpenFileDialog dlgOpen.Filter = "Zip Files (*.zip)|*.zip" dlgOpen.ShowDialog() If dlgOpen.FileName <> "" Then Zip = New C1ZipFile Zip.Open(dlgOpen.FileName) Else GoTo LoadError End If Exit Sub LoadError: 'MsgBox("There was an error loading the zip file", MsgBoxStyle.Exclamation, "FreeZip") End Sub Quote
Administrators PlausiblyDamp Posted October 6, 2004 Administrators Posted October 6, 2004 You are not declaring the variable Zip anywhere else are you? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
CrookDawg Posted October 6, 2004 Author Posted October 6, 2004 You are not declaring the variable Zip anywhere else are you? No the declaration in the module is the only delcaration Quote
Administrators PlausiblyDamp Posted October 6, 2004 Administrators Posted October 6, 2004 Any chance you could attach the project (minus binaries please) as I can't see anything wrong in those snippets. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
CrookDawg Posted October 6, 2004 Author Posted October 6, 2004 Any chance you could attach the project (minus binaries please) as I can't see anything wrong in those snippets. here it is thanks for your helpFreeZip.zip Quote
Administrators PlausiblyDamp Posted October 7, 2004 Administrators Posted October 7, 2004 In the frmMain.vb you have the line Friend WithEvents Zip As C1.C1Zip.C1ZipFile but you do not initialise it anywhere - this will effectively shadow the other declaration of Zip. If you comment out the above line does it make a difference? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
CrookDawg Posted October 7, 2004 Author Posted October 7, 2004 In the frmMain.vb you have the line Friend WithEvents Zip As C1.C1Zip.C1ZipFile but you do not initialise it anywhere - this will effectively shadow the other declaration of Zip. If you comment out the above line does it make a difference? Yes that helped, however now i get access denied error in every places except C:\ (i get a "not a valid path" error there) thanks for your help there. i can't believe i missed it. any chance you know how to solve this access denied error? (i even tried a new directory such as C:\ziptest\ but it still gives me access denied) thanks -matt Quote
Administrators PlausiblyDamp Posted October 7, 2004 Administrators Posted October 7, 2004 Are you getting these errors on all attempts to open a file (I can't test it here as I don't have the component 1 dlls installed for the C1ZipFile stuff). What OS are you running on? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
CrookDawg Posted October 7, 2004 Author Posted October 7, 2004 Are you getting these errors on all attempts to open a file (I can't test it here as I don't have the component 1 dlls installed for the C1ZipFile stuff). What OS are you running on? the errors im getting are when i try to extract a file. i can open the zip just fine but when i got to extract to ANY directory i get the error. i am running Win XP Home thanks -matt Quote
Administrators PlausiblyDamp Posted October 7, 2004 Administrators Posted October 7, 2004 Is the ZipFile part of the VB Resource Kit? If so I can download it and have a look tomorrow. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
CrookDawg Posted October 7, 2004 Author Posted October 7, 2004 Is the ZipFile part of the VB Resource Kit? If so I can download it and have a look tomorrow. Yes the one by ComponentOne thanks for the quick response -matt Quote
Administrators PlausiblyDamp Posted October 8, 2004 Administrators Posted October 8, 2004 (edited) Didn't get time to have a proper look unfortunately, however I noticed that in the routine Public Shared Sub ExtractAll(ByVal lstFiles As ListView, ByVal ExtractPath As String) Dim lvi As ListViewItem Dim ze As C1.C1Zip.C1ZipEntry For Each lvi In lstFiles.Items ze = lvi.Tag Zip.Entries.Extract(lvi.Index, ExtractPath) 'Declarations.Zip.Entries.Extract(lvi.Index, txtPath.Text) Next End Sub you are extracting just to a path and IIRC you need to specify a full path and filename to extract to. Also check you are using the correct listviewitem to generate the file name. Also you are using an awful lot of legacy VB6 syntax - you may want to consider converting to the newer .Net syntax. Edited October 8, 2004 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
CrookDawg Posted October 8, 2004 Author Posted October 8, 2004 Didn't get time to have a proper look unfortunately, however I noticed that in the routine Public Shared Sub ExtractAll(ByVal lstFiles As ListView, ByVal ExtractPath As String) Dim lvi As ListViewItem Dim ze As C1.C1Zip.C1ZipEntry For Each lvi In lstFiles.Items ze = lvi.Tag Zip.Entries.Extract(lvi.Index, ExtractPath) 'Declarations.Zip.Entries.Extract(lvi.Index, txtPath.Text) Next End Sub you are extracting just to a path and IIRC you need to specify a full path and filename to extract to. Also check you are using the correct listviewitem to generate the file name. Also you are using an awful lot of legacy VB6 syntax - you may want to consider converting to the newer .Net syntax. thank you for your help. this sorted this problem (access denied). i know im using a lot of vb6 syntax (im still a student and i was trained in vb6). im working on changing to .net syntax. Also i get another error that i think is unrelated to the previous. When i close the extract form, i get an error: An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in system.windows.forms.dll Additional information: External component has thrown an exception. i have no idea what this means. thanks for all your help -matt Quote
Administrators PlausiblyDamp Posted October 9, 2004 Administrators Posted October 9, 2004 Does this exception get thrown everytime you close the form? If so does a particular line generate the error? Is there any information to indicate which component raised this exception? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.