FileStream

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • [Gho]

    FileStream

    Hi
    IO open a file steream for reading , but i want this file
    to be changed by other application .
    I trying the following line code to open it for reading
    only :

    FileStream Headerfp = new FileStream
    (path,FileMode. Open,System.IO. FileAccess.Read );

    but now i can't write to this file from other
    application , How to open this file for read only and to
    be able to write to this file by other application
  • Kerry Sanders

    #2
    Re: FileStream

    >FileStream Headerfp = new FileStream[color=blue]
    >(path,FileMode .Open,System.IO .FileAccess.Rea d);[/color]


    The third parameter in this particular overload of the FileStream
    constructor is how your program is allowed to access the underlying
    file.

    What you need is the following:

    FileStream Headerfp = new FileStream(path , FileMode.Open,
    System.IO.FileA ccess.Read, System.IO.FileS hare.ReadWrite) ;

    This is an overload of the FileStream constructor which also accepts a
    parameter called FileShare which determines how the file will be
    shared by other processes.

    See also: http://tinyurl.com/sbfg

    Comment

    Working...