要将我的临时文件写入哪里? [英] Where to write my temporary files to?
问题描述
我有很多byte []代表pdf.每个字节数组都需要在应用程序的开头加载,并在我的GUI上显示为缩略图.到目前为止,我已经设法使用以下命令将文件写入临时位置:
I have numerous byte[] representing pdf's. Each byte array needs to be loaded at the start of the application and shown as a thumbnail on my gui. So far I have managed to write the files to a temp location using:
System.IO.Path.GetTempPath();
然后使用此路径获取所有pdf文件,使用
Then using this path I get all pdf files, write them using
System.IO.File.WriteAllBytes(fileName, arrayOfPdfs[i]);
,然后导航到该目录,获取所有pdf文件,并将它们转换为我的应用程序中的缩略图.
and then navigate to that directory, get all pdf files and turn them in to thumbnails in my app.
问题是我只希望将刚刚放置在临时位置的pdf文件保存起来,所以我还能如何存储这些pdf文件,甚至还能将它们存储在其他位置,所以我知道何时将它们转为缩略图,我正在读取的文件是我刚刚写的文件?这样可以确保用户只查看与他们在我的系统上搜索相关的pdf.
The thing is I only want the pdfs I have just put in the temp location only, so how else can I store the pdfs, or even where else can I store them so I know when I come to turn them in to thumbnails, the files I am reading are the ones I have just written? This is so I can be sure the user is only looking at the relevant pdfs that relate to their search on my system.
谢谢.
推荐答案
I would recommend in your users ApplicationData/LocalApplicationData folder provided by the OS for your app..
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
当然,如果存储不需要保持很长时间(实际上是临时的),那么您可以使用temp文件夹并在其中创建一个文件夹来隔离文件.
Of course if the storage doesn't need to persist very long (really temporary) then you could just use the temp folder and create a folder inside of it to isolate your files.
这篇关于要将我的临时文件写入哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!