Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 31st, 2007, 08:58 PM
Authorized User
 
Join Date: Jan 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default UNC Network Path

Right i am trying to access a network path. which i know exist. I have tested my code locally and it works but when i go to put it onto the server that is where the problem lies. The code that i am using is as follows if someone sees anything

Code:
'convert our source path into a physical path
                Dim sourcePath As String = "\\server\work\" & mJob.Insert(2, "-") & "\LvTest\notapproved"
                'get our destination path as physical
                Dim destPath As String = "\\server\work\" & mJob.Insert(2, "-") & "\LvLsr"
                Try
                    CopyDirectory(sourcePath, sourcePath + "\Archive", True, True)
                    CopyDirectory(sourcePath, destPath, True, False)
                Catch exc As System.Exception
                    'do nothing
                End Try
Code:
Private Sub CopyDirectory(ByVal sourcePath As String, ByVal destPath As String, ByVal overwrite As Boolean, ByVal archive As Boolean)
        Dim sourceDir As System.IO.DirectoryInfo = New System.IO.DirectoryInfo(sourcePath)
        Dim destDir As System.IO.DirectoryInfo = New System.IO.DirectoryInfo(destPath)
        'the source directory must exist for our code to run
        If (sourceDir.Exists) Then
            'if the destination folder does not exist, create it
            If Not (destDir.Exists) Then
                destDir.Create()
            End If
            'loop through all the files of the current directory
            'and copy them if overwrite=true or they do not exist
            Dim file As System.IO.FileInfo
            For Each file In sourceDir.GetFiles()
                If (overwrite) Then
                    file.CopyTo(System.IO.Path.Combine(destDir.FullName, file.Name), True)
                    If (archive = False) Then
                        file.Delete()
                    End If
                Else
                    If ((System.IO.File.Exists(System.IO.Path.Combine(destDir.FullName, file.Name))) = False) Then
                        file.CopyTo(System.IO.Path.Combine(destDir.FullName, file.Name), False)
                        If (archive = False) Then
                            file.Delete()
                        End If
                    End If
                End If
            Next
            'loop through all the subfolders and call this method recursively
            'Dim dir As System.IO.DirectoryInfo
            'For Each dir In sourceDir.GetDirectories()
            '    If (dir.FullName <> Server.MapPath(tbxDestinationDir.Text)) Then
            '        CopyDirectory(dir.FullName, System.IO.Path.Combine(destDir.FullName, dir.Name), overwrite)
            '    End If
            'Next
            'lblStatusMessage.Text = "Folder copied successfully"
            'lblStatusMessage.Visible = True
            'if source directory does not exist

        End If
    End Sub
Also i have tested to make sure the path is right from the server

 
Old February 1st, 2007, 11:28 AM
Authorized User
 
Join Date: Jan 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Never mind i have figured out i had the Reponse.Redirect in a try catch block and that is what was causing problems so i just moved that out and it is working perfectly. I think






Similar Threads
Thread Thread Starter Forum Replies Last Post
Retriving UNC Path of mapped drive (Linux Folder) kaushalparik ASP.NET 2.0 Professional 2 April 5th, 2007 09:58 PM
copy to network path with batch file saban Assembly Language 1 March 29th, 2006 12:29 PM
Filesystemobject and UNC paths dlfisher1972 Pro VB 6 0 January 5th, 2006 01:44 PM
Using UNC in data source rguidry Classic ASP Databases 2 March 29th, 2005 10:02 AM
Get UNC for a local file Mitch Access 0 August 12th, 2003 02:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.