程序问题:我怎样才能获得文件名? [英] Program question:how can i get the file name?

查看:94
本文介绍了程序问题:我怎样才能获得文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我能在程序中获取属于文件集的文件名吗?我应该如何编写程序?


如何在文件集中重命名文件?


在阅读"DryadLinq和DSC程序员指南"之后,我找不到实现这一目的的方法。 / p>

谢谢。


xfengm


 


 

解决方案

您好,


您无法重命名文件集中的文件。文件集是文件的集合,但文件集中的文件只有在写入DSC并且文件集已被密封后才是只读的。您可以修改DSC文件集中的文件或重命名它。您尝试这样做的
是什么意味着您需要重命名文件集中的文件?


以下代码将列出文件集中的所有文件副本: 


 


DscFileSet
fs = context.DscService.GetFileSet(
"" );


控制台 。WriteLine( " File
设置:{0}"
,fs.Name);


foreach
DscFile
f

fs.GetFiles())


    foreach
string
p

f.ReadPaths)


        Console 。WriteLine( "
 包含文件{0}"
,p);


hi,

Am i able to get the file name,which belongs to a fileset,in the program?How should i write the program?

How can i rename the file in a fileset?

After reading the "DryadLinq and DSC programmers guide",i did not find a way to realize this.

Thanks.

xfengm

 

 

解决方案

Hi,

You cannot rename a file in a fileset. A fileset is a collection of files but the files within a fileset are read-only once they have been written to DSC and the Fileset has been sealed. You canot modify files within a DSC fileset or rename it. What are you trying to do that means that you need to rename files in a fileset?

The following code will list all the file replicas in a fileset: 

 

DscFileSet fs = context.DscService.GetFileSet("");

Console.WriteLine("File set: {0}", fs.Name);

foreach (DscFile f in fs.GetFiles())

    foreach (string p in f.ReadPaths)

        Console.WriteLine("   Contains file {0}", p);


这篇关于程序问题:我怎样才能获得文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆