我一直在开发一个c#图像查看器,它将从我的计算机中读取图像并在程序中显示它们。
//foreach file in path display the filename
foreach (var filename in Directory.GetFiles(<path>))
{
MessageBox.show(filename);
}
//Get image by number
var image = Directory.GetFiles(<path>).elementatordefault(<picnumber>).tostring());
我
我正在尝试解析一个文件夹并删除其中的所有文件。
DirectoryInfo dir = new DirectoryInfo("C\\Temp");
if (dir.GetDirectories().Any(p => p.Name == "\\NewTemp"))
{
foreach (string file in Directory.GetFiles(dir + "\\NewTemp"))
{
File.SetAttributes(file, FileAttributes.Normal);
F
我正在编写一个小程序,它应该用文件名重命名所选目录中的多个文件。我现在用的是:
Dim sourcePath As String = dir
Dim searchPattern As String = "*." & ComboBox3.Text
Dim i As Integer = 1
For Each fileName As String In Directory.GetFiles(sourcePath, searchPattern, SearchOption.AllDirectories)
File.Move(Path
我想用iTextSharp创建一个新的pdf文件。我的所有代码都工作正常,但新文件不是按页码排序的。 您能让我知道如何修改以下代码,以创建新的pdf文件按文件名排序(页码) foreach (var file in Directory.GetFiles(path))
{
reader = new PdfReader(file);
for (int i = 0; i < reader.NumberOfPages; i++)
{
page = pdf.GetImportedPage(reader, i + 1);
pdf.AddPa
我已经创建了一个构造函数类来调用来构建我的列表,但是我得到了一个错误:
错误System.Collections.Generic.List<string>' toSystem.Collections.Generic.List‘:不能隐式转换类型CS0029
我很困惑,因为我以为文件列表是字符串。我需要把类型转换成什么?
// Create Constructor Class
public class ImagePath
{
public string path;
public ImagePath (string newPath)
{
我现在在做一个小型的迷你游戏。游戏有能力打开一些选项,在选项中你可以点击“使音乐”例如。因为应用程序太大,包括音频文件,我希望用户选择如果他想要音乐,并必须下载,或不。
我对此选项使用异步任务,因为这些选项应该在下载时弹出,到目前为止,这是我的代码:
public void CheckForFiles()
{
// searches the current directory and sub directory
int fCount = Directory.GetFiles(path, "*", SearchOption.
我有一个小程序可以重命名文件夹中的文件。在这一点上,它几乎是有效的;唯一的问题是,我希望程序重命名文件的名称字母顺序。这是我现在的剧本:
If TextBox4.Text = "" Or txtbSti.Text = "" Or ComboBox3.Text = "" Then
MsgBox("Du må velge målmappe og Oppdatere Ønsket Output!", MsgBoxStyle.OkOnly, "Ooooops!")
Else
Dim AntallFiler
我已经插入了上传文件的代码和它的工作,但问题是,我想上传图像是在图像名称表,音乐在音乐表列,还有一件事是,我没有从任何数据库,只是目录文件夹将可以。
这里是我的剃刀html所有的文件都上传到一个目录中,是否有代码将.jpg扩展到图像列,将mp3扩展到mp3列?或者是有编码的
<table>
@foreach (var f in Directory.GetFiles(Server.MapPath(@ViewBag.UploadURL)))
{
var fileInfo = new FileInfo(f);
ViewBag.FileNoE
我的代码: var files = Directory.GetFiles("c:\\a\\b\\projectfolder\\folder1", "*.jpg");
var files2 = Directory.GetFiles("c:\\a\\b\\projectfolder\\folder2", "*.jpg"); 我可以在解决方案资源管理器上看到folder1和folder2文件夹。当项目移动到另一个location.what代码时,我想避免出现问题,我应该编写吗?当然,下面的代码并没有发生。 var files =
我需要把文本框中的所有数字转换成一个平均值。
我的代码:
Dim dMods1 = "\\DirectPathToSpecificFolder"
Dim dMods2 = "\\DirectPathToSpecificFolder"
Dim dMods3 = "\\DirectPathToSpecificFolder"
Dim dMods4 = "\\DirectPathToSpecificFolder"
Dim fileCount1 As Integer = Directory.GetFiles(dMods1).Length
在VB.NET中,我试图读取文本文件(例如文件夹中的第5个文本文件);下面的代码只读取所有文件并只写下最后一个文件的值:
Imports System
Imports System.IO
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim MekdamFolder As String
MekdamFolder = Application.ExecutablePath.Remove(Application.Executa
我需要将源目录中的文件覆盖到目标目录。每个文件夹的结构都是不同的,所以我尝试用一种通用的方式。问题是,每个文件夹(源和目标)可能有许多子目录,也可能根本没有子目录。
我目前的代码是这样的:
//copy and overwrite the files depending on whatever is in the destination
//search through the destination to find the file
foreach (var dstfile in Directory.GetFiles(targetDir))
{
//search through the