Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem reading network file

Status
Not open for further replies.
Oct 5, 1999
105
0
0
GB
I am having problems opening a file on my network.

I am running VB6 under Windows 7, trying to read from a file on a different pc (running XP).

If I open the file as pathname "\\PC0\DOCS\Folder1\TEST.TXT" then it works OK
However \\PC0\DOCS is mapped on boot to T: but if I try opening "T:\Folder1\TEST.TXT" then it fails as file not found.
Using Windows Explorer on drive T: I can see all my folders and files (and no, it was not just me typing the wrong path - I double checked :) ) - I even copied the path direct from Explorer to make sure I got it right.
I have tried using DIR and FileSystemObject as well as just Open, but none of them can find the file.

HOWEVER, if I then use CommonDialog.Open to find the file then after that all works fine

Any ideas what CommonDialog does to make the drive visible to VB6?
 

So why not just use UNC "\\PC0\DOCS\Folder1\TEST.TXT"? It will work no matter which drive letter it is assgned to. In my book that would be the prefered way anyway....

Have fun.

---- Andy
 
Questions I'd wonder about:

Have you messed with UAC?​
Just how are you mapping this drive at boot?​
Are you running the IDE elevated?​
Are you running the compiled EXE elevated?​

An admin user normally has two user contexts due to the split-token mechanism, and only one is in effect for any given process. A drive mapping can be set in one context and not exist at all in the other.

I can't imagine where .ShowOpen might fit into this though.
 
No change to UAC, and drive is mapped by using Explorer "map drive" tool with reconnect at startup ticked.

BUT I am running the IDE elevated as that was the only way I could get it to run at the time without getting strange error messages (I had urgent work to do on a new PC). I suppose I should uninstall VB6 and try reinstalling to get it to run normally, if I can find out what to do!

And yes, it works OK using the compiled version (not elevated). Having discovered the problem while in the IDE I had not bothered to compile it. Should have tried.

Thanks for help. I still don't quite understand why this happened, but it will not now be a problem.
 
You could also elevate and map the drive as well as elevating it for the SU token as now.

Easiest way is to do it from an elevated command prompt, though you might be able to elevate a run of Explorer to do it too.

Or you could map the drive at the system level, through a startup script or by using psexec (SysInternals tool).
 
You may be being blocked by a request for a user and/or password that is not visible?

I have had horrible problems with full file access to computers using Win7 from an XP computer.
The only way I found reliable is to completely share the c drive(as below) and use \\IPaddress\Drive\FileName rather than using a drive letter.
Eg \\123.234.231.2\C\MyFolder\MyFile.txt

Windows 7 seems to do everything it can to stop people having general access and wants you to share only individual folders. The following might be applicable to your problem but destroys the extra security Win7 provides if any of the computers are connected to the internet as well -

Unless you set the permissions on drive c to Everyone you may see the shared folder directly and not as a sub folder on the c drive eg ComputerName\MyFolder\Myfilename.txt
This is the procedure I use:-

To share C: in Windows7 open Windows Explorer
Right click on main C: Drive in 'Computer' and select 'Advanced Sharing'
Select 'Advanced Sharing' in the new dialog box that appears
Select 'Share this folder' tick box
Select Security
Select Edit
Add 'Everyone' (Type Everyone in the space)
Give Everyone full control permissions tick box
Apply
Continue to select continue a few times if error boxes appear until done.(This is Windows folders refusing to being shared)
Check again Drive C: is shared and repeat Share this folder & set full control if not.
In Network and sharing Center select 'Advanced sharing settings'
Expand Public(Current profile)
Turn ON network discovery
Turn ON file and printer sharing
Turn ON Public folder sharing
Turn OFF password protected sharing
Save changes

Verify that you can see the C: drive of this new computer in the other's Windows Explorer without having to enter any usernames or passwords and you can see the other computer's files (username may be required to see files although just being able to see it is sufficient at this stage).
Verification can be done by entering the IP address (example \\103.208.39.123) of the other computer in Windows Explorer. The current IP address of a computer is found by selecting Accessories/'Command prompt' and typing Ipconfig.

Then sharing as a drive letter may work
 
Hmm, but his point was that he isn't having (or already got past) and actualy sharing issues. He was only seeing odd things from within his program.
 
Sorry I misread the first sentence of his problem
My problem was the reverse. I was trying to read WIN7 files FROM an XP computer
The above advice then doesn't count in this case

Was it because it somehow thought DOCS was a file and not a folder ( \\PC0\DOCS and not \\PC0\DOCS\ )?
 
Could be.

But I find myself misreading a lot of posts lately too. I probably need new glasses, less background sound here, or more frequent restroom breaks... or maybe all of the above.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top