File.Copy Method timing issues.

Discussion in 'ASP .Net' started by Brian Hanson, Feb 6, 2004.

  1. Brian Hanson

    Brian Hanson Guest

    Hi,

    I have a problem that is sporadic and am thinking it may come down to
    a timing issue. I have an asp.net (vb) app that used the
    system.io.file.copy method to copy a .pdf file from a network drive to
    the local server drive. From there I use that .pdf file to create
    another .pdf file using a tool from ActivePDF. The problem I have is
    that one out of 8 or 10 times I get an error:

    Access to the path "c:\ActivePDF\watever.pdf" is denied.

    This is the file I just copied from the network and am trying to use
    for something else.

    If I try it again, it usually works right away. Since it usually
    works, I can eliminate any permission issues, and wonder if it is a
    timing issue.
    I thought that the file.copy method was synchronous so it will finish
    its copy before moving on to the next bit of code. I then looked at
    the indexing features of the folder the file was being copied to and
    made sure that indexing was turned off. I have not, however,
    eliminated ActivePDF from being the problem child.

    Thanks for any ideas.
    Brian Hanson, Feb 6, 2004
    #1
    1. Advertising

  2. Hi,


    Thanks for posting in the community!
    From your description, you used the System.IO.File.Copy method to copy a
    file from a remote address and then use it in an ASP.NET web application.
    However, you found that sometimes there occured Access Denied error at
    runtime. Also, you suspect it was caused by time issue, yes?
    If there is anything I misunderstood, please feel free to let me know.

    Based on my experience, access resource on remote site will often caused
    security issues. But since you've mentioned that the error is after file's
    been copied to local and it works well usually. I also doubt whether it is
    caused by
    concurrency issue on the copied file. Would you please try the following
    steps:
    1. copying file from a local different folder rather than a network driver
    to see whether the problem remains. then, we can confirm whether this is
    likely caused by the time issue or not.

    2. Also , you can try accessing(read) the file after it has been copied(in
    a try... catch ...block) so as to determined whether it is concurrent
    visited or completely copied.

    Please check out the above things, if the situation is not quite suitable,
    please feel free to let me know.



    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    Steven Cheng[MSFT], Feb 7, 2004
    #2
    1. Advertising

  3. Hi,


    Have you had a chance to try out the preceding suggestions I provided in
    the last reply or have you got any progress on this issue? If you need any
    further assistance, please feel free to post here.



    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    Steven Cheng[MSFT], Feb 10, 2004
    #3
  4. Brian Hanson

    Brian Hanson Guest

    Hi,

    Thanks for replying (twice). I made a couple of changes programatically
    that may have solved my problem.

    1) I removed a loop, that because of other reasons, I no longer needed.
    2) I removed a random number generator I was using to come up with a
    unique file name and added time stamp. I may be crazy, but It seems to
    me that the random number generator in .net is not all that random.

    I have run about 50 tests without getting the error. Still more testing
    to go, because it was sporatic in the first place, but hopefully, that
    did the trick.

    Thanks

    Brian


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Brian Hanson, Feb 10, 2004
    #4
  5. Hi Brian,


    Thanks for your followup and the latest info you provided. I'm glad you've
    got progress on this issue. In addition, if you meet problem in the
    furture, please always feel free to post here. We are willing to help you.



    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    Steven Cheng[MSFT], Feb 11, 2004
    #5
  6. Brian Hanson

    Tim Sullivan Guest

    Brian,

    > 2) I removed a random number generator I was using to come up with a
    > unique file name and added time stamp. I may be crazy, but It seems to
    > me that the random number generator in .net is not all that random.


    FYI - The GetUniqueFileName method of Toolkit will generate a truly
    unique filename for you. That method also works for simultaneous
    unique name creation across processes and threads.

    Tim Sullivan
    Tim Sullivan, Feb 11, 2004
    #6
  7. Brian Hanson

    Amit Singla Guest

    hi Steven,

    I also have the similar problem. i am not able to copy the image file
    from the remote machine to the client machine dynamically at the
    specified location at the run time through ASp.net using VB.net.Can you
    please help me regarding this.


    Looking forward to hearing from you soon.

    Regards,
    Amit Singla
    Software Engineer




    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Amit Singla, Feb 20, 2004
    #7
  8. Brian Hanson

    Amit Singla Guest

    hi Steven,

    I also have the similar problem. i am not able to copy the image file
    from the remote machine to the client machine dynamically at the
    specified location at the run time through ASp.net using VB.net.Can you
    please help me regarding this.


    Looking forward to hearing from you soon.

    Regards,
    Amit Singla
    Software Engineer




    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Amit Singla, Feb 20, 2004
    #8
  9. Steven Cheng[MSFT], Feb 21, 2004
    #9
  10. Brian Hanson

    J33 Guest

    Hi, I've The Same Problem.

    I Can't Copy A Local File To Some Server With File.copy In Vb.net,,
    For Example: (source, Destination) If Destination Is A Url Path, Th
    File HavenĀ“t Been Copied

    --
    J33Posted from http://www.pcreview.co.uk/ newsgroup acces
    J33, Jun 5, 2005
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    354
    Brock Allen
    Mar 14, 2005
  2. Alex
    Replies:
    2
    Views:
    1,218
  3. Replies:
    26
    Views:
    2,107
    Roland Pibinger
    Sep 1, 2006
  4. jaquesgrobler

    Timing issues !!! help help!

    jaquesgrobler, May 8, 2008, in forum: VHDL
    Replies:
    0
    Views:
    507
    jaquesgrobler
    May 8, 2008
  5. joe
    Replies:
    2
    Views:
    138
Loading...

Share This Page