根据文件大小将文件写入文件夹 [英] Write files to folders according to file size
本文介绍了根据文件大小将文件写入文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我需要帮助。我有一个文件列表,我想根据文件大小写入4个文件夹。是否可以在vb.net中执行此操作?
谢谢。
Hi There,
I am in need of help. I have a list of files that I want to write to 4 folders according to their file size. Is it possible to do this in vb.net?
thanks.
推荐答案
有可能,你必须先检查文件大小您可以根据需要将它们与大小分开。
检查以下内容:
如何:在Visual Basic中确定文件的大小 [ ^ ]
It is possible, you have to just check the file size first and after that you can separate them with if case by size as you want.
Check the follows:
How to: Determine a File's Size in Visual Basic[^]
Dim infoReader As System.IO.FileInfo
infoReader = My.Computer.FileSystem.GetFileInfo("C:\testfile.txt")
MsgBox("File is " & infoReader.Length & " bytes.")
您可以使用以下内容:
You can use this as the follows:
Dim infoReader As System.IO.FileInfo
infoReader = My.Computer.FileSystem.GetFileInfo("C:\testfile.txt")
If infoReader.Length < 1000 Then
'your code for separation
Else
'your code for equal or bigger than 1000 bytes file
End If
当然可以。使用 FileInfo.Length [ ^ ]属性,用于检索文件的长度和然后复制( FileInfo.CopyTo [ ^ ])相应的。
Of course it is possible. Use the FileInfo.Length[^] property for retrieving the length on the files and then copy (FileInfo.CopyTo[^]) them accordingly.
这篇关于根据文件大小将文件写入文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文