我有这个循环:
foreach (DirectoryInfo dir in downloadedMessageInfo.GetDirectories())
{
if (dir.Attributes != FileAttributes.Hidden)
{
dir.Delete(true);
}
}
Run Code Online (Sandbox Code Playgroud)
如何正确跳过所有隐藏目录?
我有这个CAML:
query.Query = @"<Where><Eq><FieldRef Name='MessageID' /><Value Type='Text'></Value></Eq></Where>";
Run Code Online (Sandbox Code Playgroud)
这将检查MessageID = string.empty()的值
我想检查的是null ....不是空字符串...
这可能与CAML有关吗?
我真的在寻找一个小代码片段,或者是关于这个主题的好教程.
我有一个C#控制台应用程序,我将用它以某种方式将列表项添加到我的自定义列表.我也创建了一个自定义内容类型.因此不确定是否需要从此内容类型创建C#类.也许不是.
提前致谢
我有一个功能,发送消息(很多)和他们的附件.
它基本上循环遍历目录结构,并从文件结构创建电子邮件
c:\emails\message01
\attachments
c:\emails\message02
\attachments
Run Code Online (Sandbox Code Playgroud)
使用.net c#,标准内容创建消息.
创建所有消息后......我有另一个直接运行的函数,它将消息文件夹复制到另一个位置.
问题是 - 文件被锁定了......
注意:我没有移动文件,只是复制它们....
有关如何使用c#复制锁定文件的任何建议?
更新
我有这个添加附件方法
private void AddAttachments(MailMessage mail)
{
string attachmentDirectoryPath = "c:\messages\message1";
DirectoryInfo attachmentDirectory = new DirectoryInfo(attachmentDirectoryPath);
FileInfo[] attachments = attachmentDirectory.GetFiles();
foreach (FileInfo attachment in attachments)
{
mail.Attachments.Add(new Attachment(attachment.FullName));
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个我正在调用的Web服务方法,它是第三方和我的域之外.由于某种原因,Web服务偶尔会出现网关超时.它的间歇性和在尝试失败后直接调用它可以成功.
现在我有一个编码困境,我有代码应该做的伎俩,但代码看起来像业余时间,你会在下面看到.
这是非常糟糕的代码,还是可以接受的?如果不能接受,我该如何改进呢?
在看的同时请努力保持笔直.
try
{
MDO = OperationsWebService.MessageDownload(MI);
}
catch
{
try
{
MDO = OperationsWebService.MessageDownload(MI);
}
catch
{
try
{
MDO = OperationsWebService.MessageDownload(MI);
}
catch
{
try
{
MDO = OperationsWebService.MessageDownload(MI);
}
catch
{
try
{
MDO = OperationsWebService.MessageDownload(MI);
}
catch (Exception ex)
{
// 5 retries, ok now log and deal with the error.
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 可能重复:
获取SQL Server数据的脚本
我想将一些表(在一台服务器上)移动到另一台(在另一台服务器上).
表模式是相同的,我需要做的是生成一些插入语句.有没有办法使用一些内置/最佳实践方式?
进口/出口似乎完全极端和过度.
提前致谢.
我基本上希望调度程序计时器对象只执行一次.
所以我有基本代码:
DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Interval = new TimeSpan(0, 0, 4);
dispatcherTimer.Start();
Run Code Online (Sandbox Code Playgroud)
然后在click事件中:
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
this.Visibility = System.Windows.Visibility.Visible;
// Now stop timer execution.. or kill the timer object
}
Run Code Online (Sandbox Code Playgroud)
如何在执行后停止计时器或终止对象?
我遇到了一些奇怪的行为,试图获取以某个字符串开头的文件.
请有人就此提供一个有效的例子:
我想获取一个以某个字符串开头的目录中的所有文件,但也包含xml扩展名.
例如:
apples_01.xml
apples_02.xml
pears_03.xml
Run Code Online (Sandbox Code Playgroud)
我希望能够获得以苹果开头的文件.
到目前为止,我有这个代码
DirectoryInfo taskDirectory = new DirectoryInfo(this.taskDirectoryPath);
FileInfo[] taskFiles = taskDirectory.GetFiles("*.xml");
Run Code Online (Sandbox Code Playgroud) 我有以下代码
DirectoryInfo taskDirectory = new DirectoryInfo(this.taskDirectoryPath);
FileInfo[] taskFiles = taskDirectory.GetFiles("*" + blah + "*.xml");
Run Code Online (Sandbox Code Playgroud)
我想按文件名对列表进行排序.
如何使用.net v2尽可能快速,轻松地完成此操作.
c# ×7
.net ×3
sharepoint ×2
.net-2.0 ×1
content-type ×1
datetime ×1
locked-files ×1
smtp ×1
sql ×1
sql-server ×1
wpf ×1