如果文件夹中有多个媒体文件,如下所示:
MediaFiles(folder)
-> file1.mp4
-> file2.mp4
...
Run Code Online (Sandbox Code Playgroud)
当我们选择所有文件并
Right Click -> Properties
Run Code Online (Sandbox Code Playgroud)
在详细信息选项卡上的属性窗口中,有一个长度字段,显示媒体文件的总运行时间,如下所示:
是否可以使用 C# 获取此信息?
我有一个xml文件,里面有变音符号,如下所示:
<NameGe>ËÇ</NameGe>
Run Code Online (Sandbox Code Playgroud)
有没有办法读取此文件并将其写出来:
<NameGe>Öç</NameGe>
Run Code Online (Sandbox Code Playgroud)
所以基本上应该写出变音符号的数值/编码值.
问候.
我有一个像这样的字符串数组
May#01
April#02
Jan#03
Run Code Online (Sandbox Code Playgroud)
我需要按字母顺序排序,然后按#旁边的数值排序.字母排序是显而易见的,但我似乎没有得到数字部分.
我使用VS 2017创建了一个简单的Azure功能来测试工具.
这是项目:
这是发布屏幕:
单击"发布"按钮不会显示任何进度,但我可以在门户网站上看到新功能.但是,已发布的函数只有function.json和没有csx文件.
我究竟做错了什么?
提前致谢.问候.
配置文件中是否有一个设置可以在EntLib中打开或关闭日志记录.有帖子显示如何以编程方式执行此操作,但我有兴趣通过配置文件执行此操作.
我正在使用EntLib 5.
这是配置
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
<listeners>
<add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
source="Enterprise Library Logging" formatter="Text Formatter"
log="" machineName="." traceOutputOptions="None" />
<add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="c:\\Log\\wclog.log" header=""
formatter="Text Formatter" traceOutputOptions="DateTime, Timestamp" />
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
template="Timestamp:{timestamp} Method: {title}, {category} {message}"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="Flat File Trace …Run Code Online (Sandbox Code Playgroud) 我有一个ASP.NET MVC应用程序,它允许用户选择存储在ViewModel中的日期.
这是转换为日期对象的代码:
viewModel.startDateAndTime = Convert.ToDateTime(buyToday.DealStartDateAndTime);
Run Code Online (Sandbox Code Playgroud)
其中一位开发人员将其系统日期时间设置为以下格式:
24月2014
在那个系统上,他得到了FormatException.我想设置使用这种格式的日期时间:
毫米/日/年
无论任何系统的设置是什么..
尝试使用这段不起作用的代码:
string startDate = "24-Feb-2014";
DateTime startDateTime = DateTime.ParseExact(startDate, "mmddyyyy", CultureInfo.InvariantCulture);
Run Code Online (Sandbox Code Playgroud)
任何线索都值得赞赏.感谢和问候.
我正在尝试使用AutoFac,并且所有示例都使用构造函数注入来显示它,这是一种建议的做法.没关系,但我想知道如何在无法进行构造函数注入的情况下使用它.例如,我想在我的应用程序中使用NLogger.
注册如下:
builder.RegisterType<NLogger>().As<ILogger>().SingleInstance();
Run Code Online (Sandbox Code Playgroud)
如何在不执行此操作的情况下使用NLogger:
public class ProductService : IProductService
{
private ILogger _logger;
public ProductService(ILogger logger)
{
this._logger = logger;
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助是极大的赞赏.
问候.
考虑这段代码:
public async Task<Status> SendMessage(Message message)
{
List<IMessage> _messageDispatchers = new List<IMessage>();
try
{
Object[] args = new Object[] { _message };
IMessage endpoint = (IMessage)Activator.CreateInstance(Type.GetType(_message.AgentDLLName), args);
_messageDispatchers.Add(endpoint);
foreach (IMessage dispatcher in _messageDispatchers)
{
await Task.Run(() => dispatcher.SendMessage(_message));
}
return await Task.Run(() => Status.Success);
}
catch (Exception ex)
{
logger.Log(LoggerLevel.Error, ex.Message);
return Status.EmailSendingFailed;
}
}
Run Code Online (Sandbox Code Playgroud)
发送消息:
public async Task<Status> SendMessage(OutboundMessage outboundmessage)
{
string strMessage = string.Empty;
string subject = string.Empty;
MessageServices objService = new MessageServices();
try
{
var config = …Run Code Online (Sandbox Code Playgroud) 我有以下JS函数,可在弹出窗口中显示日期列表。
在返回所需数据的AJAX调用之后调用此函数。
function Show(currentSchedule) {
var scheduleDates = currentSchedule.Dates.join(", ");
bootbox.dialog({
title: "Preview",
message: "<div class='row'><div class='box'>" + scheduleDates + "</div></div>"
});
}
Run Code Online (Sandbox Code Playgroud)
单击按钮时将调用此选项,它将日期显示为逗号分隔的值。
为了以表格格式显示此内容,我查看了Datatables.js库。
它需要一个模板表,期望的数据将被注入其中。当您在页面上显示数据时,这很好用。
<table style="width:100%" id="previewTable" class="table table-striped table-bordered">
<thead>
<tr>
<th>
Date(s)
</th>
</tr>
</thead>
<tbody></tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚的是一种在弹出窗口而不是页面中显示表格的方法。
提前致谢。
我有一个像文件一样的xml
<Config>
<Allowed></Allowed>
</Config>
Run Code Online (Sandbox Code Playgroud)
Allowed标记如下所示:
string isAllowed = (string)xml.Root
.Element("Config")
.Elements("Allowed")
.SingleOrDefault();
Run Code Online (Sandbox Code Playgroud)
isAllowed应该采用默认值true
这是执行此操作的代码:
if (isAllowed == null)
{
DoSomething();
return true;
}
if (isAllowed.Length == 0)
{
DoSomething();
return true;
}
if (isAllowed.Length != 0)
{
if (isAllowed.ToUpper() != "FALSE" && isAllowed.ToUpper() != "NO")
{
DoSomething();
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
必须有更好的方法来做到这一点?
所以我有这样的代码:
foreach (var optionValues in productOption.ProductOptionValues)
{
if (optionValues.ProductOptionValueID > 0)
{
unitOfWork.ProductContext.Entry(optionValues).State = EntityState.Modified;
}
else
{
unitOfWork.ProductContext.Entry(optionValues).State = EntityState.Added;
}
}
Run Code Online (Sandbox Code Playgroud)
对此的代码审查是我应该看看使用LINQ来做到这一点.
有人可以指点我可以解释使用LINQ更改对象属性的资源吗?
我正在浏览一段C#代码,如下所示:
if (((long)ShopperId != 0) && ((long)ShopperId != null) && ((long)ShopperId != '0'))
Run Code Online (Sandbox Code Playgroud)
我理解前两个检查,但第三个检查呢?这甚至是一个有效的C#语句.
然而,这已经生产了一段时间,没有任何错误.