使用UWP打开Runfulltrust Desktop应用程序打破桌面应用程序
这确实没有任何意义。我有一个UWP应用程序,标题为firstUWP
。它自己打开了。
我有一个称为scrren.exe
的桌面扩展程序,利用Tesseract从屏幕上读取一些图像。首先打开我的UWP,然后单独打开scrren.exe
,都可以正常运行。
但是,当我使用UWP的Runfulltrust启动器时,scrren.exe
无法写入UWP项目下的文件。
当它们完全单独启动时,scrren.exe
可以写入文件夹,而当UWP启动它scrren.exe
无法写入文件夹中时UWP。
该代码是桌面扩展中发生问题的地方sccren.exe
。我还附加了一个屏幕截图,显示了UWP中的资产树,显示了我的问题起源的图像文件夹。在此之下,我附加了一个屏幕截图,显示了我的意思是,当从UWP中启动时,scrren.exe
显示在UWPS父母名称下,但这是我得到错误的地方,scrren.exe.exe.exe
无法写入图像
文件夹。
我真的希望这是有道理的。
string result = Assembly.GetExecutingAssembly().Location;
int index = result.LastIndexOf("\\");
string rootPath = $"{result.Substring(0, index)}\\..\\";
using (Bitmap bitmap1 = new Bitmap(bounds.Width, bounds.Height))
{
using (Graphics g = Graphics.FromImage(bitmap1))
{
g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
}
try
{
using (bitmap1)
{
bitmap1.Save((rootPath + @"Scrn\Images\test.png"), System.Drawing.Imaging.ImageFormat.Png);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "Right here");
}
// Sleep for one second in order to let the file properly save
Thread.Sleep(1000);
}
” ://i.sstatic.net/ulvo5.png“ alt =”在此处输入图像说明”>
This really does not make any sense. I have a UWP application, titled FirstUWP
. It opens fine on its own.
I have a desktop extension that I made called scrren.exe
, taking advantage of tesseract to read some image from the screen. When first opening my UWP and then opening up the scrren.exe
on it's own, both run fine.
However, when I use the runfulltrust launcher from UWP, the scrren.exe
cannot write to a file that is under the UWP's project.
When they are launched entirely separately, the scrren.exe
can write to the folder fine, it is just when the UWP launches it the scrren.exe
cannot write to the folder within the UWP.
This code is the place where the problem occurs within the Desktop Extension sccren.exe
. I've also attached a screenshot showing the Assets tree within the UWP, showing the Images folder which seems to be where my problems originate. Below that, I attached a screenshot showing what I mean that when launched from within UWP, scrren.exe
shows up under the UWPs parent name, but this is where I get errors and scrren.exe
cannot write to the Images
folder.
I really hope this makes sense.
string result = Assembly.GetExecutingAssembly().Location;
int index = result.LastIndexOf("\\");
string rootPath = quot;{result.Substring(0, index)}\\..\\";
using (Bitmap bitmap1 = new Bitmap(bounds.Width, bounds.Height))
{
using (Graphics g = Graphics.FromImage(bitmap1))
{
g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
}
try
{
using (bitmap1)
{
bitmap1.Save((rootPath + @"Scrn\Images\test.png"), System.Drawing.Imaging.ImageFormat.Png);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "Right here");
}
// Sleep for one second in order to let the file properly save
Thread.Sleep(1000);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法写入包装应用程序的安装位置;它是只读的。相反,您应该使用 applicationdata.current.localfolder 获取用于保存文件的本地文件夹。
另外,请确保您正在使用 full trustProcessLauncher 启动您的EXE,而不是
process.start()
。You can't write to a packaged app's install location; it is read-only. Instead you should be using
ApplicationData.Current.LocalFolder
to get the local folder for saving files.Also make sure you are using
FullTrustProcessLauncher
to launch your exe, not something likeProcess.Start()
.