Results 1 to 6 of 6

Thread: Premision denied saveasfile kill...

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    6

    Premision denied saveasfile kill...

    Hi
    i am trying to save an attachment for temproray use and then delete it afterwards and i keep getting premission denied error when i want to delete the attachment :/

    For Each eItem In Inbox.Items
    If eItem.UnRead = True Then
    For Each atmt In eItem.Attachments
    If Right(atmt.FileName, 3) = "xml" Then


    atmtP = "C:\" & atmt.FileName

    atmt.SaveAsFile atmtP
    'NOW WHEN I TRY TO DO THIS FOR EXAMPLE
    kill atmtP ' i get premision denied error



    any help would be great thanks...

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Premision denied saveasfile kill...

    Welcome to the Forums.

    Is your "attachment" a file that is open?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    6

    Re: Premision denied saveasfile kill...

    Hi,

    no the file is closed.


    what i do is that i loop through the un read emails and save their attachment for temporary use, because the attachment has some xml in it so i parse it and then i need to delete the temporary file. so the file is supposed to be closed. the thing is once i use saveasfile to save a temporary attachment file i can't delete it even if i manually try to delete it from outside outlook until i exit from outlook. somehow outlook takes control over the file i think :S.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Premision denied saveasfile kill...

    Is the temp attachment file still have any references tied to it like a file stream or file system object?

    Can you post your SaveAs code procedure?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    6

    Re: Premision denied saveasfile kill...

    yeap your right, i found out the source of the problem, when I save the attachment file

    atmt.SaveAsFile atmtP

    If ((xmlt.ValidateXML(atmtP, schemaP)) = True) Then '<--PROBLEM WITH THIS METHOD
    ....
    End If

    i pass the atmtP to a method which checks if the attachment is of valid xml
    schema, when ever i call this method i can't do anything with the file anymore, i think it keeps it open or something, anywayz the xml thingy is
    written by a friend using c# and i am just using his .tlb reference, so i have to waite for him to check if he forgot to close the file or something, thanks heaps <>_<>

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Premision denied saveasfile kill...

    Yup, sounds like atmtP has a reference left instanciated. It may be being passed byref in the arguments which will pass the actual object instead of a copy. .NET pases objects ByRef as a default where VB6/VBA passes ByVal.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width