non
(non)
1
listを作成していてループでフォルダ名を変数指定していますが上手くいきません。
下記は変数指定をしていない場合のファイルパスです。
“C:\Users\PCuser\XDRIVE\RPA\未成工事一覧\〇〇\未成工事改.exe”
変数指定場所は、〇〇の箇所→部署入力.Tostring()
"C:\Users\PCuser\XDRIVE\RPA\未成工事一覧"+部署入力.Tostring()
この後に、\未成工事改.exe"をつなげたいのですが上手くいきません。
教えてもらえますでしょうか。
rlgandu
(Rajyalakshmi Gandu)
2
@non
"C:\Users\PCuser\XDRIVE\RPA\Unfinished Works List\" + DepartmentInput.ToString() + "\Unfinished Works Reform.exe"
supriya117
(Supriya Allada)
3
Hi @non
Try this:
folderPath = "C:\Users\PCuser\XDRIVE\RPA\List of uncompleted constructions" + Department.ToString()
filePath = Path.Combine(folderPath, “未成工改.exe”)
or
filePath = Path.Combine(“C:\Users\PCuser\XDRIVE\RPA\List of uncompleted constructions”, Department.ToString(), “未成工改.exe”)
lrtetala
(Lakshman Reddy)
4
Hi @non
How about this
fullFilePath = Path.Combine("C:\Users\PCuser\XDRIVE\RPA\List of uncompleted constructions",Department.Tostring(), "未成工改.exe")
Cheers!!
non
(non)
5
rlgandu Rlganduさんのファイルパスを最初に試したところ上手くいきました!!
皆さん有難うございました。
Yoichi
(Yoichi)
6
こんにちは
どのようにうまくいかないか共有いただくと良いかと思います。
パス区切り文字がうまくつかないのであればSystem.IO.Path.Combineを使うか文字補間を使うと良いかと思います。
部署入力の型がStringなら
System.IO.Path.Combine("C:\Users\PCuser\XDRIVE\RPA\未成工事一覧",部署入力,"未成工事改.exe")
部署入力の型がString以外なら
System.IO.Path.Combine("C:\Users\PCuser\XDRIVE\RPA\未成工事一覧",部署入力.ToString(),"未成工事改.exe")
あるいは文字補間を使うなら
strVar=部署入力.ToString()
としておいて
$"C:\Users\PCuser\XDRIVE\RPA\未成工事一覧\{strVar}\未成工事改.exe"
とすれば{strVar}の部分がstrVarの内容に置き換わります。(先頭の$が必要です)
あるいは区切り文字以外でうまくいかない:例えばファイルパスで使えない文字などもありますので、その場合はそのあたりを共有いただくと良いかと思います。
rlgandu
(Rajyalakshmi Gandu)
7
@non
If it is worked for you please mark it as solution.Thank you
system
(system)
Closed
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.