获取完整路径位置并将其发送到 CMD window
Getting full path location and sending it to CMD window
所以我一直在研究一种从 adb 保存备份的方法,我想到的最好的方法是:
saveFileDialog1.Title = "Save Backup";
saveFileDialog1.OverwritePrompt = true;
saveFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
var process = Process.Start("CMD.exe", "/c adb backup -apk -all -f"+saveFileDialog1.FileName);
process.WaitForExit();
}
但是,无论我将文件保存在哪里,它都没有将文件置于测试名称下。难道我做错了什么?
我的 openFileDialog 也一样:
openFileDialog1.Title = "Open Backup";
openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
var process = Process.Start("adb.exe", "restore"+openFileDialog1.FileName);
process.WaitForExit();
}
您的参数格式不正确。您在以下行中缺少 space:
var process = Process.Start("CMD.exe", "/c adb backup -apk -all -f"+saveFileDialog1.FileName);
-f"+saveFileDialog1.FileName
应该是 -f "+saveFileDialog1.FileName
。
您还应该将文件名括在引号中以处理文件路径中的 spaces:
var process = Process.Start("CMD.exe", "/c adb backup -apk -all -f \""+saveFileDialog1.FileName+"\"");
所以我一直在研究一种从 adb 保存备份的方法,我想到的最好的方法是:
saveFileDialog1.Title = "Save Backup";
saveFileDialog1.OverwritePrompt = true;
saveFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
var process = Process.Start("CMD.exe", "/c adb backup -apk -all -f"+saveFileDialog1.FileName);
process.WaitForExit();
}
但是,无论我将文件保存在哪里,它都没有将文件置于测试名称下。难道我做错了什么? 我的 openFileDialog 也一样:
openFileDialog1.Title = "Open Backup";
openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
var process = Process.Start("adb.exe", "restore"+openFileDialog1.FileName);
process.WaitForExit();
}
您的参数格式不正确。您在以下行中缺少 space:
var process = Process.Start("CMD.exe", "/c adb backup -apk -all -f"+saveFileDialog1.FileName);
-f"+saveFileDialog1.FileName
应该是 -f "+saveFileDialog1.FileName
。
您还应该将文件名括在引号中以处理文件路径中的 spaces:
var process = Process.Start("CMD.exe", "/c adb backup -apk -all -f \""+saveFileDialog1.FileName+"\"");