我正在编写一个VB.NET控制台应用程序,它采用相对路径并吐出所有文件名,或者输出无效错误.我无法从相对路径获取PhysicalPath
例:
我在文件夹中 C:\Documents and Settings\MehdiAnis.ULTIMATEBANGLA\My Documents\Visual Studio 2005\Projects\SP_Sol\SP_Proj\bin\Debug
我的应用程序SP.exe也在同一个文件夹中.
我跑:"SP.exe ..\".输出将是文件夹中所有文件的列表"C:\Documents and Settings\MehdiAnis.ULTIMATEBANGLA\My Documents\Visual Studio 2005\Projects\SP_Sol\SP_Proj\bin"
我跑:"SP.exe ..\\..\".输出将是文件夹中所有文件的列表"C:\Documents and Settings\MehdiAnis.ULTIMATEBANGLA\My Documents\Visual Studio 2005\Projects\SP_Sol\SP_Proj"
我跑:"SP.exe ..\\..\\..\".输出将是文件夹中所有文件的列表"C:\Documents and Settings\MehdiAnis.ULTIMATEBANGLA\My Documents\Visual Studio 2005\Projects\SP_Sol"
目前我正在处理一个相对路径,但不再:
If Source.IndexOf("..\") = 0 Then
Dim Sibling As String = Directory.GetParent(Directory.GetCurrentDirectory()).ToString()())
Source = Source.Replace("..\", Sibling)
End If
Run Code Online (Sandbox Code Playgroud)
我怎样才能轻松处理多个..\?
考虑一下我有一个共享功能: -
Public Shared Function CalculateAreaFromRadius(ByVal radius As Double) As Double
' square the radius...
Dim radiusSquared As Double
radiusSquared = radius * radius
' multiply it by pi...
Dim result As Double
result = radiusSquared * Math.PI
'Wait a bit, for the sake of testing and
'simulate another call will be made b4 earlier one ended or such
for i as Integer = 0 to integer.Max
Next
' return the result...
Return result
End Function
Run Code Online (Sandbox Code Playgroud)
我的问题:
如果我在同一个vb .net应用程序中有两个或多个线程,并且每个线程同时使用不同的RADIUS调用共享函数,那么它们每个都会获得自己的AREA吗?
我想知道每次调用函数是否使用相同的局部变量或者每次调用都会创建局部变量的新实例? …