English 中文(简体)
现有工作名录的复印件
原标题:Copying file from current working directory to another folder

I m试图复制VB现有工作名录的档案(pdftk.exe)。 该网络方案正在进行。

档案将抄送Folder Dialog Browser的选定路径。

我尝试了这部法律,但似乎并没有奏效。

Imports System
Imports System.IO

Public Partial Class MainForm

    Dim Hours As Integer
    Dim Mins As Integer
    Dim Secs As Integer
    Dim Time As Integer 
    Dim nmTime As String

    Dim FileCopy As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "pdftk.exe"
    Dim FileCopyPath As String = FileCopy.ToString


    Public Sub New()

        Me.InitializeComponent()

    End Sub

    Sub Button1Click(sender As Object, e As EventArgs)



        If dlgFolder.ShowDialog = Windows.Forms.DialogResult.OK Then

            txtPath.Text = dlgFolder.SelectedPath
            System.IO.File.Copy(_System.IO.Path.Combine(_System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName.CodeBase,_"pdftk.exe")_,dlgFolder.SelectedPath)

        End If

    End Sub

    Sub DlgFolderHelpRequest(sender As Object, e As EventArgs)




    End Sub

    Sub TxtPathTextChanged(sender As Object, e As EventArgs)

        txtPath.Text = dlgFolder.SelectedPath
        txtPath.Show

    End Sub

    Sub LblCurrTimeClick(sender As Object, e As EventArgs)



    End Sub

    Sub MainFormLoad(sender As Object, e As EventArgs)



        Me.timer1.Interval = 1 * 1000
        Me.timer1.Enabled = True    

        rdMerge.Checked = True



    End Sub


    Private Sub Timer1Tick(ByVal sender As System.Object,     ByVal e As System.EventArgs) 


            Me.lblCurrTime.Text = Now.ToLongTimeString

            Dim currTime As String = Now.ToLongTimeString
            Dim selTime As String = nmTime



            If currTime = selTime Then

                If Not (rdSWF.Checked = True) Then

                    Beep

                    Dim myProcess As Process

                    File.Copy("pdfmerge.py", dlgFolder.SelectedPath)


                    myProcess.Start("pdfmerge.py")

                Else 

                    Beep                

                    Dim myProcess As Process

                    File.Copy("p2f.bat", dlgFolder.SelectedPath)


                    myProcess.Start("p2f.bat")

                End If  

              End If


    End Sub

    Sub BtnSetClick(sender As Object, e As EventArgs)

        lbl8.Visible = True

        nmTime = nmHour.Value.ToString().PadLeft(2,"0") + ":" + nmMin.Value.ToString().PadLeft(2, "0") + ":" + nmSec.Value.ToString().PadLeft(2, "0")

        lblST.Text = (nmTime)

        lblST.Visible = True
        pctBox1.Visible = True

    End Sub

    Sub BtnSwfClick(sender As Object, e As EventArgs)

        Dim myProcess As Process


        Beep    

        File.Copy("p2f.bat", dlgFolder.SelectedPath)

        myProcess.Start("p2f.bat")


    End Sub

    Sub BtnNowClick(sender As Object, e As EventArgs)

        Dim myProcess As Process        
        myProcess.Start("pdfmerge.py")


    End Sub



    Sub Panel1Paint(sender As Object, e As PaintEventArgs)



    End Sub


End Class

在试图执行该法典时,我从夸张中获得了以下错误信息:

System.ArgumentException: URI formats are not supported.
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength)
   at System.IO.Path.GetFullPathInternal(String path)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)
   at System.IO.File.Copy(String sourceFileName, String destFileName)
   at lgaPDF.MainForm.Button1Click(Object sender, EventArgs e) in C:Documents and Settingsstudent3My DocumentsSharpDevelop ProjectslgaPDFlgaPDFMainForm.vb:line 29
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
   at System.Windows.Forms.Control.WmCommand(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
   at System.Windows.Forms.Control.DefWndProc(Message& m)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   at lgaPDF.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81

该方案应当从目前的工作名录(节目前的目录)中获取“pdftk.exe”,并将它复制到从博客窗口中选定的途径。

最佳回答

大多数用途的数据类型最差。 如果你可以避免使用这些工具,至少会尝试使用正确的东西。

在大多数情况下,这种方法所恢复的体力包括通往但并不包括最后一位目录的所有特性。

Which would mean that if you directly concatenate a filename onto the end of it, you ll end up with a path that ends LastDirectoryNamepdftk.exe, which probably doesn t exist.

Path.Combine 是专门设计的一种方法,目的是共同走路,使目录分离器正确。


你的<代码>FileCopyPath变量似乎特别毫无意义。 本条采用<代码>FileCopy,即<编码>String,并注明<编码>ToString(>,并将结果作为<编码>String予以储存。 你们期望达到什么目标?

Similarly, the SelectedPath property of the FolderBrowserDialog is already a string, so why are you calling ToString() on it?


d 我期望正确的法典是:

System.IO.File.Copy( _
    System.IO.Path.Combine( _
         System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase), _
         "pdftk.exe"), _
    dlgFolder.SelectedPath)
问题回答

暂无回答




相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签