如何删除日期超过X天的文件.这很简单,但我在一个文件夹中只记录了一天.我的NLog.config看起来像:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true">
<extensions>
<add assembly="NLog.Extended" />
</extensions>
<variable name="LogHome" value="PATH"/>
<variable name="DailyDir" value="${LogHome}${date:format=yyyy}/${date:format=MM}/${date:format=dd}/"/>
<targets>
<target name="asyncFile" xsi:type="AsyncWrapper">
<target
name="fatalLog"
xsi:type="File"
layout="${longdate}|${callsite}|${message}|${exception}"
fileName="${DailyDir}/Fatal.txt"
/>
</target>
<target name="asyncFile" xsi:type="AsyncWrapper">
<target
name="errorLog"
xsi:type="File"
layout="${longdate}|${callsite}|${message}|${exception}"
fileName="${DailyDir}/Error.txt"
/>
</target>
</targets>
<rules>
<logger name="*" level="Fatal" writeTo="fatalLog" />
<logger name="*" level="Error" writeTo="errorLog" />
</rules>
</nlog>
Run Code Online (Sandbox Code Playgroud) 我的应用程序应保存相机中的图像.我写了下面的代码:
初始化相机的方法.
Windows.Media.Capture.MediaCapture takePhotoManager;
public async void InitializeCamera()
{
takePhotoManager = new Windows.Media.Capture.MediaCapture();
await takePhotoManager.InitializeAsync();
takePhotoManager.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
PhotoPreview.Source = takePhotoManager;
await takePhotoManager.StartPreviewAsync();
// to stop it
//await takePhotoManager.StopPreviewAsync();
}
Run Code Online (Sandbox Code Playgroud)保存照片的方法:
public async void SavePhoto()
{
ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg();
var file = await KnownFolders.PicturesLibrary.CreateFileAsync("Photo.jpg", CreationCollisionOption.ReplaceExisting);
await takePhotoManager.CapturePhotoToStorageFileAsync(imgFormat, file);
}
Run Code Online (Sandbox Code Playgroud)预习
<CaptureElement x:Name="PhotoPreview" FlowDirection="LeftToRight"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stretch="UniformToFill">
</CaptureElement>
Run Code Online (Sandbox Code Playgroud)我有两个问题:1.预览不会填满整个空间


谢谢
我正在使用 .NET core 3.1 开发后端应用程序。我从旧项目(.NET core 2.1)中移出了CommonResource ,该项目运行良好。我想获取指定文化中密钥的值。公共资源的实现:
public class CommonResource : ICommonResource
{
private readonly IStringLocalizer<SharedResource> _localizer;
public CommonResource(
IStringLocalizer<SharedResource> localizer)
{
_localizer = localizer;
}
#region ICommonResource Members
#region General
public string AppName(
string language)
=> GetString(language, nameof(AppName));
#endregion
#endregion
/// <summary>
/// Dispose of class and parent classes
/// </summary>
public void Dispose()
=> GC.SuppressFinalize(this);
private string GetString(
string language,
string name)
{
var currentCulture = CultureInfo.CurrentCulture;
CultureInfo.CurrentCulture = new CultureInfo(language);
var value = _localizer[name]; …Run Code Online (Sandbox Code Playgroud) 我编写了方法,它从许多来源向List添加元素.见下文:
public static async Task<List<SearchingItem>> GetItemsToSelect()
{
List<SearchingItem> searchingItems = new List<SearchingItem>();
foreach (Place place in await GetPlaces())
{
searchingItems.Add(new SearchingItem() {
IdFromRealModel=place.Id, NameToDisplay=place.FullName,
ExtraInformation=place.Name, TypeOfSearchingItem=TypeOfSearchingItem.PLACE });
}
foreach (Group group in await GetGroups())
{
searchingItems.Add(new SearchingItem()
{
IdFromRealModel = group.Id, NameToDisplay = group.Name,
ExtraInformation = group.TypeName, TypeOfSearchingItem = TypeOfSearchingItem.GROUP
});
}
return searchingItems;
}
Run Code Online (Sandbox Code Playgroud)
我测试了这种方法,并且有效地工作.我想,它的工作原理propertly,因为GetPlaces方法返回160元和GetGroups返回3000但是,我在想,如果,如果方法返回的同时元素会工作.我应该锁定列表searchItems吗?
谢谢你的建议.
在我的Azure应用服务中,我想更新应用程序设置,但在从VS发布后,密钥不会覆盖本地Web.config中的值
在结果中,我的azure上的web.config包含来自本地设置的值
<connectionStrings>
<add name="MainConnectionString" connectionString="ConnectionStringToReplaceByAzure" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="MS_SigningKey" value="Overridden by portal settings" />
</appSettings>
Run Code Online (Sandbox Code Playgroud) connection-string azure application-settings azure-web-sites
我想在Visual Studio 2015中使用远程调试器附加到我的站点.当我尝试"附加调试器"时,azure返回: 启动远程调试时出现以下错误:无法连接到Microsoft Visual Studio远程调试器名称"XXXX".Windows身份验证无法与远程计算机建立安全连接.
在azure portal中,我设置了远程调试并选择了VS 2015.
我想在Windows Phone 8.1应用程序(WPF)中自定义我的视图.在我的桌面项目中,我使用了以下内容:
<Grid>
<Grid.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding IsTrueValue}" Value="False">
<Setter Property="Visibility" Value="Hidden" />
</DataTrigger>
<DataTrigger Binding="{Binding IsTrueValue}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
</Grid>
Run Code Online (Sandbox Code Playgroud)
不幸的是,Style.Triggers无法识别.
谢谢你的帮助.
在我的 Azure Mobile .NET 后端中,我想使用Azure Mobile .NET Server Swagger。我正在寻找快速的方法来隐藏 swagger UI 不让公众访问?有没有办法只为选定的用户提供访问权限?
c# ×4
azure ×3
asp.net-core ×1
asp.net-mvc ×1
async-await ×1
asynchronous ×1
debugging ×1
multitasking ×1
nlog ×1
rotation ×1
swagger ×1
swagger-ui ×1
triggers ×1
wpf ×1