Link to home
Start Free TrialLog in
Avatar of jskfan
jskfanFlag for Cyprus

asked on

FileStream in VB.net

I have some questions regarding the code below:

Dim sdirectory as string="C:\vb.net\files"
dim sfile as string="example.txt"
dim spath as string= sdirectory & sfile
dim sfilestrean as filestream
sfilestream=new filestream(spath,filemode.open,fileaccess.readwrite)


1-can I just use: dim spath as string="C:\vb.net\files\example.txt" instead of declaring Dim sdirectory as string="C:\vb.net\files"  then dim sfile as string="example.txt"?

2-when I put filemode.open, Fileaccess.write or Fileaccess.readwrite or Fileaccess.read or Fileaccess.none.   Does this mean if that file exists and accesseb by another user while this code is running can allow/prevent that user from read or write? please explain.


3- when I put filemode.createnew, Fileaccess.write or Fileaccess.readwrite or Fileaccess.read or Fileaccess.none.   Does this mean if that file exists and accesseb by another user while this code is running can allow/prevent that user from read or write? please explain.

Thanks

ASKER CERTIFIED SOLUTION
Avatar of nayernaguib
nayernaguib
Flag of Egypt image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jskfan

ASKER

If a user runs the application that has:
 filemode.open, Fileaccess.write

and the file was already open by another user for reading or writing , what would heappen?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial