通过python修改cmd路径_通过cmd将文件路径传递到python脚本

我正在使用vb.net版以及我的程序的Arcobjects。我正在为arcmap10创建一个按钮,它将把kml转换成lyr文件。在

我在向python代码中传递变量时遇到问题。变量是文件路径,如果我用/而不是硬编码它们,效果会很好。动态传入变量时,程序在路径名中的“/”处中断:Dim Filelocation As OpenFileDialog = New OpenFileDialog()

Filelocation.Title = "Please point photo of the owner"

Filelocation.InitialDirectory = "B:\GeoSpatialData\Projects\004402 Griffiths\File Structure\Geospatial\GPS\KML"

If Filelocation.ShowDialog = DialogResult.OK Then

Dim kmlFile As String

kmlFile = Filelocation.FileName

Dim args As String

args = kmlFile & " " & kmlFile.Substring(0, kmlFile.LastIndexOf("\")) & " test"

Dim args2 As String = args.Replace("\", "/")

Dim procStartInfo As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo("C:\Python26\python", "C:\Users\KJacobsen\kml_to_shp.py " & args2)

' The following commands are needed to redirect the standard output.

' This means that it will be redirected to the Process.StandardOutput StreamReader.

procStartInfo.RedirectStandardOutput = True

procStartInfo.UseShellExecute = False

' Do not create the black window.

procStartInfo.CreateNoWindow = False

' Now you create a process, assign its ProcessStartInfo, and start it.

Dim proc As New System.Diagnostics.Process()

proc.StartInfo = procStartInfo

proc.Start()

proc.WaitForExit()

' Get the output into a string.

Dim result As String = proc.StandardOutput.ReadToEnd()

' Display the command output.

Console.WriteLine(result)

End If

Catch objException As Exception

' Log the exception and errors.

Console.WriteLine(objException.Message)

End Try

我的python脚本如下所示:

^{pr2}$

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值