Locking File

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ron Vecchi

    #1

    Locking File

    Hello,

    I am opening a file like below:
    FileStream fs =
    File.Open(Serve r.MapPath("../Data/REFCOD.txt"),Fi leMode.Open,Fil eAccess.Writ
    e,FileShare.Non e);

    ---------------------------------------------------------
    I do not want anyone to access the file while it is opened.
    ---------------------------------------------------------


    My question is:
    If another request tries to open this file while it is opened will the
    request wait untill it can open it and then proceed with its operation or
    will an exception be generated?

    I'm hopeing that it will wait untill it can open it and then will.
    If not is there a way todo so with out generating an exception?


    Thanks,
    Ron Vecchi


  • bruce barker

    #2
    Re: Locking File

    execption thrown

    "Ron Vecchi" <vencenzo@comca st.net> wrote in message
    news:OB7IeQUUDH A.2008@TK2MSFTN GP11.phx.gbl...[color=blue]
    > Hello,
    >
    > I am opening a file like below:
    > FileStream fs =
    >[/color]
    File.Open(Serve r.MapPath("../Data/REFCOD.txt"),Fi leMode.Open,Fil eAccess.Writ[color=blue]
    > e,FileShare.Non e);
    >
    > ---------------------------------------------------------
    > I do not want anyone to access the file while it is opened.
    > ---------------------------------------------------------
    >
    >
    > My question is:
    > If another request tries to open this file while it is opened will the
    > request wait untill it can open it and then proceed with its operation or
    > will an exception be generated?
    >
    > I'm hopeing that it will wait untill it can open it and then will.
    > If not is there a way todo so with out generating an exception?
    >
    >
    > Thanks,
    > Ron Vecchi
    >
    >[/color]


    Comment

    • Ron Vecchi

      #3
      Re: Locking File

      Rats,



      "bruce barker" <nospam_brubar@ safeco.com> wrote in message
      news:%23yAANlUU DHA.2420@TK2MSF TNGP10.phx.gbl. ..[color=blue]
      > execption thrown
      >
      > "Ron Vecchi" <vencenzo@comca st.net> wrote in message
      > news:OB7IeQUUDH A.2008@TK2MSFTN GP11.phx.gbl...[color=green]
      > > Hello,
      > >
      > > I am opening a file like below:
      > > FileStream fs =
      > >[/color]
      >[/color]
      File.Open(Serve r.MapPath("../Data/REFCOD.txt"),Fi leMode.Open,Fil eAccess.Writ[color=blue][color=green]
      > > e,FileShare.Non e);
      > >
      > > ---------------------------------------------------------
      > > I do not want anyone to access the file while it is opened.
      > > ---------------------------------------------------------
      > >
      > >
      > > My question is:
      > > If another request tries to open this file while it is opened will the
      > > request wait untill it can open it and then proceed with its operation[/color][/color]
      or[color=blue][color=green]
      > > will an exception be generated?
      > >
      > > I'm hopeing that it will wait untill it can open it and then will.
      > > If not is there a way todo so with out generating an exception?
      > >
      > >
      > > Thanks,
      > > Ron Vecchi
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...