|
-
Mar 17th, 2005, 01:32 PM
#1
Thread Starter
Member
Path Unreachable Check
I'm writing a utility with VB.NET that pushes out new files to several locations. I'm reading in all of the locations from an INI file, but sometimes the computer might be turned off for one of my target locations. How can I check to see if the target (ie. target1=\\computer1\targetdirectory\) is reachable before copying the file? I can't seem to find a Path.Exists method or anything similar. Maybe I'm just missing it.
-
Mar 17th, 2005, 01:56 PM
#2
Re: Path Unreachable Check
You may want to try creating a temp file in that path and then use the file exists method to double check it.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 17th, 2005, 02:03 PM
#3
Re: Path Unreachable Check
VB Code:
if System.IO.Directory.Exists("\\computer1\targetdirectory\") then
'copy file
else
'dir doesnt exist
end if
-
Mar 17th, 2005, 02:25 PM
#4
Re: Path Unreachable Check
Nice, kleinma. Show me up as usual 
Your way is good but my way will make sure the files can be copied over to
in case of any permission issues.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 17th, 2005, 02:30 PM
#5
Re: Path Unreachable Check
true... but technically if I was coding this, I would check for the path to exist. if it does, then I would do the file copy in try/catch blocks, which would handle any issue like permissions...
-
Mar 17th, 2005, 03:31 PM
#6
Re: Path Unreachable Check
I think I'm having one of "those" days 
Yet again, you have the best solution.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 17th, 2005, 03:43 PM
#7
Re: Path Unreachable Check
-
Mar 17th, 2005, 03:57 PM
#8
Re: Path Unreachable Check
Actually I am feeling good today because I got my car back with new tires on the rear. Now I can
go back to racing all those punks that think they are faster then me with their little
import toy racer cars
But I do have a new thread on my UC. Its a small question.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 17th, 2005, 05:13 PM
#9
Thread Starter
Member
Re: Path Unreachable Check [RESOLVED]
 Originally Posted by kleinma
true... but technically if I was coding this, I would check for the path to exist. if it does, then I would do the file copy in try/catch blocks, which would handle any issue like permissions... 
Here's what I have working with the exception of permissions problems.
Permissions problems are what I'm dealing with now. I'll put in the try/catch. Thanks...
VB Code:
If Directory.Exists(target) Then
If File.Exists(copytarget) Then
File.Delete(copytarget)
End If
'don't copy *.scc files
Dim extcheck() As String = Split(xFiles(y), ".")
If Directory.Exists(target) Then
If UCase(extcheck(UBound(extcheck))) <> "SCC" Then
writelog.WriteLine(ControlChars.Tab & copytarget)
File.Copy(copysource, copytarget)
End If
Else
writelog.WriteLine("*************************************")
writelog.WriteLine("** Could not reach " & copytarget)
writelog.WriteLine("*************************************")
End If
Else
Dim detailmsg As String = "*************************************" & _
vbCrLf & "** Could not reach " & target & _
vbCrLf & "*************************************"
writelog.WriteLine(detailmsg)
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|