System.IO.File.Exists in Windows 7

  • Thread starter Thread starter vovan
  • Start date Start date
V

vovan

My VB 2008 application uses System.IO.File.Exists method. On XP there is no
problem with accessing file located on the server. On Windows 7 the file is
not found.
The same problem with
file_reader = New System.IO.StreamReader(strSourse & "\InitialData.txt")
where strSource is the string containing the path to the file on the server.

Any advice please.

Thank you
vovan
 
vovan said:
My VB 2008 application uses System.IO.File.Exists method. On XP there is
no problem with accessing file located on the server. On Windows 7 the
file is not found.
The same problem with
file_reader = New System.IO.StreamReader(strSourse & "\InitialData.txt")
where strSource is the string containing the path to the file on the
server.

Any advice please.

Thank you
vovan

More than likely you are seeing folder virtualization for the first
time. It did not exist in XP. Where is strSourse pointing?
 
vovan said:
My VB 2008 application uses System.IO.File.Exists method. On XP there is
no problem with accessing file located on the server. On Windows 7 the
file is not found.
The same problem with
file_reader = New System.IO.StreamReader(strSourse & "\InitialData.txt")
where strSource is the string containing the path to the file on the
server.

Unlike XP, Vista and Windows 7 are not going to allow file access to
protected areas.

Where is the file located?


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4559 (20091030) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
The file located on the server. Its location is something like
"\\192.168.45.13\CoordData\InitialData.txt"
You say Windows 7 are not going to allow file access to protected area. How
do I unprotect that area or get permission to access the file?

Thank you
vovan
 
What does it mean "folder virtualization"? The file exists in reality on the
server in the location
"\\192.168.45.13\CoordData\InitialData.txt"
My program sees it and can read when it is running on XP. I can see the file
via Windows Explorer as well on both Windows XP and Windows 7.

Thank you
vovan
 
vovan said:
What does it mean "folder virtualization"? The file exists in reality on
the server in the location
"\\192.168.45.13\CoordData\InitialData.txt"
My program sees it and can read when it is running on XP. I can see the
file via Windows Explorer as well on both Windows XP and Windows 7.

Thank you
vovan

Virtualization is the name for the thing that Mr. Arnold was describing
as well. It protects certain folders like Program Files and My
Documents, which is where I might have expected your file to reside.
This only affects certain locations on your local machine, so it does
not come into play in your scenario.

Since it is a remote file that you know exists, it must be a permissions
problem. I would have thought this would through an exception if you
did not have permission to reach a file on the net. Are you running a
windows forms application, or is this a windows service? Services also
run differently, with different permissions on the newest OS's.
 
It is Windows Form application.
I've already read about permissions and tried this:
objPermission = New
System.Security.Permissions.FileIOPermission(Security.Permissions.PermissionState.Unrestricted,
strSourse & "\InitialData.txt")
objPermission.Demand()
It did not sove my problem. Unfortunately I cannot find any example showing
how to get permissions.
I also do not understand who should have a permission - my application or my
computer, and who may give that permission - the server or my application or
something else.
From the example I found and used (see above) it most likely that my
application gives the permission to itself. If the code is correct in
general (I do not know why it doesn't work) then for me it is nonsense - to
give a permission to itself.
Anyway, I still need a help.

Thank you

vovan
 
vovan said:
It is Windows Form application.
I've already read about permissions and tried this:
objPermission = New
System.Security.Permissions.FileIOPermission(Security.Permissions.PermissionState.Unrestricted,
strSourse & "\InitialData.txt")
objPermission.Demand()
It did not sove my problem. Unfortunately I cannot find any example
showing how to get permissions.
I also do not understand who should have a permission - my application
or my computer, and who may give that permission - the server or my
application or something else.
From the example I found and used (see above) it most likely that my
application gives the permission to itself. If the code is correct in
general (I do not know why it doesn't work) then for me it is nonsense -
to give a permission to itself.
Anyway, I still need a help.

Maybe, you should put the file in a FileShare and give access to the
Fileshare to Everyone group.

A program is going to have the the file access rights of the user
account that's running the application.
 
My approach would be to start from the root . I.e. do you see the container
folder ? also what if you are using the computer name rather than the IP
address ? What if you map a drive to this network share and see if you can
see enumerate files in this folder ?

Hopefully it should allow to narrow down the problem (you don't have any
message, it just return false ?)...
 
The same problem when I use computer name instead of IP.
The same problem if I put the file in the root.
If I create a mapped drive then it works. But it is not a solution. My
clients do not want to have mapped drives on users workstations.
I'm still looking for working example of Permission object

Thank you
vovan
 
And if you enumerate files from this folder ?

This is to see which kind of exception it would give. It would likely allow
to distinguish between a right issue and some other problem.

It's really weird it works with a mapped drive but not with an UNC path...
 
vovan said:
My VB 2008 application uses System.IO.File.Exists method. On XP there is no
problem with accessing file located on the server. On Windows 7 the file is
not found.
The same problem with
file_reader = New System.IO.StreamReader(strSourse & "\InitialData.txt")
where strSource is the string containing the path to the file on the server.

I suppose you probably tried that already, but here it goes anyway:
run your application as administrator (right click it's icon and
select "Run As Administrator" from the popup menu). Report back the
result here.

HTH.

Branco.
 
Back
Top