fileinfo

c# replace string within file

安稳与你 提交于 2019-12-04 15:37:15
问题 String.Replace doesn't seem to work properly when replacing a portion of an HTML file's content. For example, String.Replace replaces </body></html> with blah blah blah </body></html> html> - notice the second HTML closing tag is not properly closed and therefore shows up when the page is rendered in the browser by the user. Anyone know why it's not working as intended? StreamReader sr = fi.OpenText; String fileContents = sr.ReadToEnd(); sr.close(); fileContents = fileContents.Replace("<body>

Akka实战:HTTP大文件断点上传、下载,秒传

别来无恙 提交于 2019-12-04 07:48:10
访问: https://github.com/yangbajing/scala-applications/tree/master/file-upload 获取本文所述完整源码,包括Akka HTTP后端和HTML5实现的前端。 在很多应用里面都会有类似大文件上传的需求,但很多时候我们程序员都会以不支持或不好实现将其推脱掉^_^。 这次因为公司项目需要,另一个组的同事使用Spring实现了一版。他们是采用在前端对大文件分块上传,后端在所有分块上传完成后合并的方式实现了。这个方案有一个弊端,若文件很大,后期对分块做合并时会非常的耗磁盘资源。 本文,我使用Akka HTTP和Akka Stream做为后端服务,可以很优雅的实现大文件的断点续传。原理其实非常的简单,前端计算文件的hash(使用sha256),将hash传到后端查询是否有相同文件已上传,若有将返回已上传文件及文件长度(bytes)。这时候前端就可以知道文件的上传进度,进而判断还需要断点续传的偏移量或者已上传完成(这就是秒传)。 这里有一个设计取舍:客户端对单个文件不做分片,从文件头开始上传。这样的一个好处是可简化服务端的实现,同时也可以优化服务端对文件的存储 (同一个文件将一直使用APPEND的方式写入文件,这样可以更高效的利用磁盘IO。同时,不需要分块合并,若文件很大

Does FileInfo.Extension return the last *.* pattern, or something else?

让人想犯罪 __ 提交于 2019-12-03 22:12:07
I'm curious what exactly the behavior is on the following: FileInfo info = new FileInfo("C:/testfile.txt.gz"); string ext = info.Extension; Will this return ".txt.gz" or ".gz"? What is the behavior with even more extensions, such as ".txt.gz.zip" or something like that? EDIT: To be clear, I've already tested this. I would like an explanation of the property. It will return .gz, but the explanation from MSDN ( FileSystemInfo.Extension Property ) isn't clear why: " The Extension property returns the FileSystemInfo extension, including the period (.). For example, for a file c:\NewFile.txt, this

SPLFileInfo: get filename without extension

ⅰ亾dé卋堺 提交于 2019-12-03 11:36:00
I'm accessing a number of files in the SPLFileInfo object. I see a way to get the path, filename, and even extension of the file. Is there a way to get the filename without extension? Here's the code I've been working with but I'm hoping to get something more elegant. Is there an out of the box solution? $file = new SplFileInfo("path/to/file.txt.zip"); echo 'basename: '.$file->getBasename(); echo PHP_EOL; echo 'filename: '.$file->getFilename(); echo PHP_EOL; echo 'extension: '.$file->getExtension(); echo PHP_EOL; echo 'basename w/o extension: '.$file->getBasename('.'.$file->getExtension()); >

Why is FileInfo showing an extra file extension?

做~自己de王妃 提交于 2019-12-02 16:46:51
问题 I have been having problems with creating a download list of files for a downloader and was getting unexplained "File Does Not Exist" returns. My .avi files were returning found but but .exe and .txt files were getting the not exists. I have now found by pulling in the whole directory and examining the file contents that my .exe files are showing ".exe.exe". My .txt files are showing ".txt.rtf". Wow, browsing the file directory in Server 2008 only shows a single extension. I don't see an

Get file's “get info” attributes in mac using python

女生的网名这么多〃 提交于 2019-12-02 12:14:38
问题 I have mounted a drive. In it's "Get Info", I have an attribute named Image Disk The location: /private/var/run/vmware/fuse/10323660103412696815/flat How can I get this attribute using python? os.stat does not give me this. 回答1: Use the getxattr function from the xattr module, which is a Python binding to the native function getxattr(2). For example: import xattr print xattr.getattr('/Volumes/MyDrive', 'Image Disk') See this blog post for a more detailed example. 来源: https://stackoverflow.com

Why is FileInfo showing an extra file extension?

陌路散爱 提交于 2019-12-02 09:46:29
I have been having problems with creating a download list of files for a downloader and was getting unexplained "File Does Not Exist" returns. My .avi files were returning found but but .exe and .txt files were getting the not exists. I have now found by pulling in the whole directory and examining the file contents that my .exe files are showing ".exe.exe". My .txt files are showing ".txt.rtf". Wow, browsing the file directory in Server 2008 only shows a single extension. I don't see an option to display the extension as a column, just the "type". My directory looks like this: Name Type File1

Get file's “get info” attributes in mac using python

半城伤御伤魂 提交于 2019-12-02 06:24:32
I have mounted a drive. In it's "Get Info", I have an attribute named Image Disk The location: /private/var/run/vmware/fuse/10323660103412696815/flat How can I get this attribute using python? os.stat does not give me this. Adam Rosenfield Use the getxattr function from the xattr module, which is a Python binding to the native function getxattr(2) . For example: import xattr print xattr.getattr('/Volumes/MyDrive', 'Image Disk') See this blog post for a more detailed example. 来源: https://stackoverflow.com/questions/11005303/get-files-get-info-attributes-in-mac-using-python

Getting file move datetime

纵饮孤独 提交于 2019-12-02 01:45:42
问题 When you copy a file (in a windows environment), the Creation and LastAccess datetime are modified and can be retrieved with a FileInfo object. However, I can't find any reliable datetime (directly linked to a file) that would be changed when a file is moved into a folder. Does windows update any datetime value in the file when it's moved (and can it be retrieved)? Note I'm not in a dead end and I have many workarounds. I'm just wondering if this could be handled directly at the file level to

Get file info from NTFS-MFT reference number

戏子无情 提交于 2019-12-01 17:44:38
In my C# application, I already have a way to examine the file system but I would like to take advantage of reading from the Master File Table (MFT) because it is so much faster. I understand that 1) it is a proprietary specification and therefore subject to change without notice, and 2) it is only accessible when the application is running under administrative privileges. I managed to read the Master File Table via this code . From the MFT query, I get a file name and a so-called file reference number. What I can't find is how to transition to a .NET FileInfo object, or even to a Windows API