在内存中创建的文件不是文件系统

编程入门 行业动态 更新时间:2024-10-25 16:20:45
本文介绍了在内存中创建的文件不是文件系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用的是.NET库函数上传文件到服务器,并作为一个参数一个文件路径。我要发送的数据小,在运行时构建的。我可以将它保存到临时文件,然后上传。

I am using a .NET library function that uploads files to a server, and takes as a parameter a path to a file. The data I want to send is small and constructed at runtime. I can save it to a temporary file and then upload it.

由于我的应用程序将被部署在各种环境中,我不知道如果我将能够可靠地创建临时文件,这将是preferable能在一个路径传递到虚拟文件在存储器

Since my application will be deployed in a variety of environments, and I don't know if I'll be able to create the temporary file reliably, it would be preferable to be able to pass in a path to a virtual file in memory.

我不能改变图书馆;我知道它在执行该文件的以下内容:

I can't change the library; I know it executes the following on the file:

LibraryUploadFunction(string filename) { fileName = Path.GetFullPath(fileName); FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); ... }

是否有可能避免写入到磁盘文件?

Is it possible to avoid writing the file to disk?

感谢

编辑:

库调用Webclient.UploadFile,如回答指出,有许多可能的解决方法,其中包括使用替代库,其中有很多。

The library call is Webclient.UploadFile, as pointed out in the answers, there are many workarounds possible, including using alternative libraries, of which there are many.

推荐答案

没有,您的图书馆在这方面根本不灵活,通过它使用的事实的FileStream 。

No, your library is fundamentally inflexible in this aspect, by the fact that it uses FileStream.

选项:

  • 使用一个RAMDRIVE并在指定的路径,以避免实际命中磁盘
  • 在不同的地方图书馆的来源,或者要求的变化(如果它是封闭源代码),或仅仅的做的,如果它是开源的变化
  • 使用不同的库。 (有什么特别之处吗?)
  • Use a ramdrive and specify a path on that, in order to avoid actually hitting disk
  • Depending on where the library comes from, either request a change (if it's closed source) or just make the change if it's open source
  • Use a different library. (What's special about this one?)

更多推荐

在内存中创建的文件不是文件系统

本文发布于:2023-05-26 19:33:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/265271.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件系统   内存   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!