Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Question regarding a lock on a file

Question regarding a lock on a file

Scheduled Pinned Locked Moved C#
questioncsharpsysadminhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thoru
    wrote on last edited by
    #1

    Hello, I think this is the first time i post a question on the codeproject, so hope it goes well:) So, the question is: How can i lock a file while it is being written so that other processes cannot move/delete or access it. I have a file that is being written into by an application on a remote machine and a windows service on the local machine that connects to the remote machine and downloads that file. The problem is that i want to download the file only after the write process has stopped completely. How can this be done? And a related question: How can this be done if i try to download the file from a ftp server. Both remote and local machine are under XP and the applications are written in c#. Thank you

    G 1 Reply Last reply
    0
    • T thoru

      Hello, I think this is the first time i post a question on the codeproject, so hope it goes well:) So, the question is: How can i lock a file while it is being written so that other processes cannot move/delete or access it. I have a file that is being written into by an application on a remote machine and a windows service on the local machine that connects to the remote machine and downloads that file. The problem is that i want to download the file only after the write process has stopped completely. How can this be done? And a related question: How can this be done if i try to download the file from a ftp server. Both remote and local machine are under XP and the applications are written in c#. Thank you

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      Pass FileShare.None to constructor of FileStream class.

      Giorgi Dalakishvili #region signature my articles #endregion

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups