简体   繁体   English

[已解决].net Maui android 如何从外部文件服务器检索文件

[英][Solved].net Maui android how to retrieve file from external fileserver

I am making an app that allows you to open and edit a pdf file on tablets.我正在制作一个应用程序,允许您在平板电脑上打开和编辑 pdf 文件。 Because i usually work with .NET, i decided to write it in .NET MAUI.因为平时工作都是.NET,所以决定写在.NET MAUI。 That way i also have access to windows tablets.这样我也可以访问 windows 平板电脑。 It uses Itext as its main library to read and edit the pdf's.它使用 Itext 作为阅读和编辑 pdf 的主要图书馆。 I have an external shared fileserver that anyone can access when they are coneected to the WIFI.我有一个外部共享文件服务器,任何人在连接到 WIFI 时都可以访问。 I'd like to access that fileserver when i connect from my android tablet using Itext pdfreader.当我使用 Itext pdfreader 从我的 android 平板电脑连接时,我想访问该文件服务器。

How do I achieve this correctly?我如何正确地实现这一目标?

Am i missing a library or a package which would allow to me to access that file?我是否缺少允许我访问该文件的库或 package?

Are there options i haven't discovered yet?有没有我还没有发现的选项?

This works on windows tablets:这适用于 windows 平板电脑:

string dest "\\\\Path\\to\\File\\";
string file = "\\\\Path\\to\\File\\file.pdf";
PdfDocument pdfDoc = new PdfDocument(new PdfReader(file), new PdfWriter(dest));

I have tried:我试过了:

string file = Environment.GetFolderPath(Environment.SpecialFolder.Windows)+ "\\Path\to\File\file.pdf";
string file = "\\\\Path\\to\\File\\file.pdf";

All of them result in file not found所有这些都导致找不到文件

Among the getfolderpath options ive tried a dozen, none of them seem to work.在我尝试了十几个的 getfolderpath 选项中,它们似乎都不起作用。

thank you for your time感谢您的时间

So i ended up solving this by transforming the document into a base64 string and sending it through an api that i had.所以我最终通过将文档转换为 base64 字符串并通过我拥有的 api 发送它来解决这个问题。

i used the classic httprequest aproach that you can look up and copy anywhere.我使用了经典的 httprequest 方法,您可以在任何地方查找和复制它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM