Results 1 to 6 of 6

Thread: FSO.MoveFile Permission Denied

  1. #1

    Thread Starter
    Hyperactive Member pgrimes's Avatar
    Join Date
    Aug 2001
    Location
    sacramento
    Posts
    342

    FSO.MoveFile Permission Denied

    I am trying to use VB .NET and the "Scripting.FileSystemObject" to move around some files. I have done this plenty of times before in asp w/ vbscript. My problem seems to be a permissions issue according to the error message.

    Here is the message I get:
    Security Exception
    Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

    Exception Details: System.Security.SecurityException: Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENIED).

    Source Error:


    Line 269: If Not objFSO.FileExists(uploadMovePath & "\" & moveFileName) Then
    Line 270: objFSO.MoveFile(cptFilePath, uploadMovePath & moveFileName)
    Line 271:



    Source File: G:\WebServer\cpthandler\processUploads\WebForm1.aspx.vb Line: 270

    Stack Trace:


    [SecurityException: Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENIED).]
    Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
    Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
    processUploads.processUpload.Page_Load(Object sender, EventArgs e) in G:\WebServer\cpthandler\processUploads\WebForm1.aspx.vb:270
    System.Web.UI.Control.OnLoad(EventArgs e)
    System.Web.UI.Control.LoadRecursive()
    System.Web.UI.Page.ProcessRequestMain()
    System.Web.UI.Page.ProcessRequest()
    System.Web.UI.Page.ProcessRequest(HttpContext context)
    System.Web.CallHandlerExecutionStep.Execute()
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    I have given modify and delete permissions to IUSR_machine, IWAM_machine, ASPNET, and at one point even the EVERYONE account, but I keep getting the same security message. I have also changed the UserName to System (password=AutoGenerate) in the machine.config file. At one point, just to test it, I even set myself (an administrator account) as the default web guest account... I still got the security error. I am able to copy files without a problem, but I can't move or delete files. Is it possible this message could be generated due to a problem other than security? There is a possibility that I'm setting the perimssions wrong... I right click on the folder that the files are moved around in, click security tab, give appropriate users modify permissions, then I click advanced, then click view/edit, and check the delete box. I also make sure that it says apply to: "this folder, subfolders and files".

    I have triple checked that the paths are corresponding to eachother correctly when I try to move the file. Here are the paths:

    Move From:
    G:\WebServer\cpthandler\SVGgraph\CPT Archive\temp\02-248.CPD

    Move To:
    G:\WebServer\cpthandler\SVGgraph\CPT Archive\2002 CPT Data\07-195901\02-248.CPD

    If you want me to post my code, let me know.


    Thanks for any help.

    Paul

  2. #2

    Thread Starter
    Hyperactive Member pgrimes's Avatar
    Join Date
    Aug 2001
    Location
    sacramento
    Posts
    342
    ps.

    I just ran some a coulpe of asp 3.0 pages, one creates a file and one deletes a file. They both work, and they create and delete the file in the same friggin' directory where the .NET is trying to move the file.

    I noticed this in the error message from .NET:

    "... or change the application's trust level in the configuration file"

    I have checked in the web.config file, but didn't really see anything in there to change. As I mentioned earlier, the machine.config file is using the System account, so, it has priv's there.

    stuck

  3. #3
    Member
    Join Date
    Jul 2002
    Posts
    49
    I think I know what this is, but not how to fix it. If you go to your control panel and open the Administrative Tools, in there you will find the Microsoft .NET Configuration program. You can use this to set the access permissions of your .net programs, but I'm not sure exactly what setting you need to modify.

  4. #4

    Thread Starter
    Hyperactive Member pgrimes's Avatar
    Join Date
    Aug 2001
    Location
    sacramento
    Posts
    342
    hmm...

    The "Microsoft .NET Framework Configuration" (mscorcfg.msc) doesn't do anything when I double click it.

    The "Microsoft .NET Framework Wizards" (ConfigWizards.exe), gives the following options:
    1.) Adjust .NET Security - this didn't help, I gave all options full
    trust, and still got my @#!*@$@#$@*&^ error
    2.) Trust an Assembly - this let's me choose from every dll and
    exe file on my computer. I can choose one and "trust the
    managed assembly". Could this be what I need to do?
    Which dll would I trust? They all seem so friendly, I just can't
    choose .

    Thanks for the reply...

    please keep any suggestions comin'


    Paul

  5. #5
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    You have to give the calling program the right security clearance for moving and deleting. Remember the framework is assuming that everone that will be using the program wont have admin right so you have to do this explicitly.

    You should have seen this from the exception that was thrown. You need to check out thee System.Security namespace. That will solve all our problems.

    Dev

  6. #6

    Thread Starter
    Hyperactive Member pgrimes's Avatar
    Join Date
    Aug 2001
    Location
    sacramento
    Posts
    342
    You have to give the calling program the right security clearance for moving and deleting. Remember the framework is assuming that everone that will be using the program wont have admin right so you have to do this explicitly.

    You should have seen this from the exception that was thrown. You need to check out thee System.Security namespace. That will solve all our problems.
    I Already did that.


    But... turns out this wasn't even a permissions problem...

    I changed the code where the file is moved from this:
    VB Code:
    1. objFSO.MoveFile(cptFilePath, uploadMovePath & moveFileName)
    to this:
    VB Code:
    1. File.Move(cptFilePath, uploadMovePath & moveFileName)
    This gave a different error message. Instead of a permission denied error, it told me what I needed to here. Cannot move "the file" because "the file" is being used by another process.

    That tipped me off real quick, and I realized that I had a streamReader open on the file I was trying to move. So, I closed the streamReader before the file gets moved and it works.

    *DOH*

    Anyway, works like a charm now. Thanks for your help... sorry I wasted your time by being a blind moron.

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