小编Sir*_*ifi的帖子

使用c#使下载可恢复

我正在使用此方法(WebClientClass)从Internet下载文件:

private Task DownloadUpdate(string url, string fileName)
{
       var wc = new WebClient();
       return wc.DownloadFileTaskAsync(new Uri(url), @"c:\download" + fileName);
}
Run Code Online (Sandbox Code Playgroud)

如何使用上述代码使下载恢复

c# asynchronous webclient-download

5
推荐指数
1
解决办法
4664
查看次数

带方向RTL的FlexSlider

你好我使用RTL网站flexslider,在这种情况下,没有图像出现,我应该设置 direction"ltr"为保持滑块一个div,它解决了我的问题,但在这种情况下,它让我的网页水平滚动, 在此输入图像描述 怎么能解决这个问题?下面是我的加价:

<div class="flexslider">

                        <ul class="slides">
                            <li data-thumb="/Content/slider/1.jpg">
                                <img src="/Content/slider/1.jpg">
                            </li>
                            <li data-thumb="/Content/slider/1.jpg">
                                <img src="/Content/slider/1.jpg">
                            </li>
                            <li data-thumb="/Content/slider/1.jpg">
                                <img src="/Content/slider/1.jpg">
                            </li>
                            <li data-thumb="/Content/slider/1.jpg">
                                <img src="/Content/slider/1.jpg">
                            </li>

                        </ul>
                    </div>
Run Code Online (Sandbox Code Playgroud)

以下是flexslider css:

/*
 * jQuery FlexSlider v2.0
 * http://www.woothemes.com/flexslider/
 *
 * Copyright 2012 WooThemes
 * Free to use under the GPLv2 license.
 * http://www.gnu.org/licenses/gpl-2.0.html
 *
 * Contributing author: Tyler Smith (@mbmufffin)
 */


/* Browser Resets */
.flex-container a:active,
.flexslider a:active,
.flex-container a:focus,
.flexslider a:focus  {outline: none;}
.slides, …
Run Code Online (Sandbox Code Playgroud)

css jquery flexslider

5
推荐指数
1
解决办法
6444
查看次数

通过Quartz.NET安排任务在特定时间每天运行

我每天使用Quartz.NET在特定时间执行任务,这是我的代码:

public class TestSchedule : ISchedule
    {
        public void Run()
        {

            DateTimeOffset startTime = DateBuilder.FutureDate(2, IntervalUnit.Second);

            IJobDetail job = JobBuilder.Create<HelloJob>()
                                       .WithIdentity("job1")
                                       .Build();

            ITrigger trigger = TriggerBuilder.Create()
                                             .WithIdentity("trigger1")
                                             .StartAt(startTime)
                                             .WithDailyTimeIntervalSchedule(x => x.OnEveryDay().StartingDailyAt(new TimeOfDay(7, 0)).WithRepeatCount(0))
                                             .Build();

            ISchedulerFactory sf = new StdSchedulerFactory();
            IScheduler sc = sf.GetScheduler();
            sc.ScheduleJob(job, trigger);

            sc.Start();
        }
    }
Run Code Online (Sandbox Code Playgroud)

我的代码正在运行,但是问题是现在只能运行一次(似乎是因为WithRepeatCount(0)),怎么能说每天7点运行?
PS:我不想CronTrigger这样做。

quartz-scheduler quartz.net

4
推荐指数
1
解决办法
5066
查看次数

'/'应用程序中的服务器错误:系统找不到指定的文件

嗨朋友,当我尝试打开网站时,我在互联网上发布了我的网站,我收到此错误: 在此输入图像描述

我的应用程序在localhost上正常工作.这是我的web.config:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <connectionStrings>
    <clear />
    <!--<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;" providerName="System.Data.SqlClient"/>-->
    <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Server=myServer;Database=myDatabase;User Id=myUser;Password=myPassword;" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings> …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc asp.net-mvc-4

4
推荐指数
1
解决办法
9122
查看次数

使用Async await方法异步读取串行端口

我用这种方式从串口读取:

public static void Main()
{
    SerialPort mySerialPort = new SerialPort("COM1");

    mySerialPort.BaudRate = 9600;
    mySerialPort.Parity = Parity.None;
    mySerialPort.StopBits = StopBits.One;
    mySerialPort.DataBits = 8;
    mySerialPort.Handshake = Handshake.None;

    mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);

    mySerialPort.Open();

    Console.WriteLine("Press any key to continue...");
    Console.WriteLine();
    Console.ReadKey();
    mySerialPort.Close();
}
private static void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
{
    SerialPort sp = (SerialPort)sender;
    string indata = sp.ReadExisting();
    Debug.Print("Data Received:");
    Debug.Print(indata);
}
Run Code Online (Sandbox Code Playgroud)

我们知道这种API称为基于事件的异步模式(EAP),我想使用Async Await方法编写上面的代码.

PS:有时上面的代码我得到错误的数据
在此先感谢

c# asynchronous serial-port async-await c#-5.0

4
推荐指数
1
解决办法
8140
查看次数

有没有办法在eclipse中生成"Lorem ipsum"?

Lorem ipsum在为虚拟文本创建视图时,我正在寻找一种在eclipse中生成的方法.例如,在Visual Studio中,只需键入lorem并按Tab键即可完成.
在eclipse中有没有做到这一点?任何的想法?

eclipse android-layout

3
推荐指数
2
解决办法
6276
查看次数

无法将“System.Web.UI.WebControls.ListItem”类型的对象转换为“System.String”类型

我的网页中有一个列表框(我正在使用 ASP.NET Web Form 4),当我想将这些列表框的项目转换为字符串数组时,它不起作用,我使用以下代码:

protected void btnSend_Click(object sender, EventArgs e)
{
    String[] a= ListBox1.Items.Cast<String>().ToArray();
}
Run Code Online (Sandbox Code Playgroud)

当我单击btnSend并通过 Chrome 开发工具(在“控制台”选项卡中)检查它时,我收到如下错误:

无法将“System.Web.UI.WebControls.ListItem”类型的对象转换为“System.String”类型

为什么会发生这种情况以及如何解决它?

c# asp.net webforms

2
推荐指数
1
解决办法
7071
查看次数

ASP.NET MVC:使用递归助手生成多级菜单

我使用此代码生成菜单,此菜单使用此技术从数据库(类别表)填充项目

局部视图:

@using SarbarzDarb.Helper
@model IEnumerable<SarbarzDarb.Models.Entities.Category>

@ShowTree(Model)

@helper ShowTree(IEnumerable<SarbarzDarb.Models.Entities.Category> categories)
{
        foreach (var item in categories)
        {
            <li class="@(item.ParentId == null && item.Children.Any() ? "dropdown-submenu" : "")">

                @Html.ActionLink(item.Name, actionName: "Category", controllerName: "Product", routeValues: new { Id = item.Id, productName = item.Name.ToSeoUrl() }, htmlAttributes: null)

                @if (item.Children.Any())
                {
                    ShowTree(item.Children);
                }

            </li>

        }
}
Run Code Online (Sandbox Code Playgroud)

我也是这样通过模型从控制器传递到局部视图以上:

public IList<Category> GetAll()
{

        return _category.Where(category => category.ParentId == null)
                        .Include(category => category.Children).ToList();
}
public ActionResult Categories()
{
            var query = GetAll();
            return PartialView("_Categories",query);
} …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc recursion entity-relationship razor ef-code-first

2
推荐指数
1
解决办法
8930
查看次数

如何通过Powershell获取所有远程计算机的用户名?

有没有办法通过Powershell获取远程计算机上所有本地用户帐户的列表?

windows powershell

2
推荐指数
1
解决办法
7149
查看次数

最有效的方法来比较两个List <T>

我想比较两个列表.这是我正在尝试使用的扩展方法:

public static bool EqualsAll<T>(this IList<T> a, IList<T> b)
{
    if (a == null || b == null)
        return (a == null && b == null);

    if (a.Count != b.Count)
        return false;

    EqualityComparer<T> comparer = EqualityComparer<T>.Default;

    for (int i = 0; i < a.Count; i++)
    {
        if (!comparer.Equals(a[i], b[i]))
            return false;
    }

    return true;
}
Run Code Online (Sandbox Code Playgroud)

我已经在这里问了这个问题.但我需要更多相关信息.回答者说最好使用SequenceEqual而不是forloop.

现在我的问题是,两种方法中的哪一种是比较两种方法的最有效方法List<T>

c# performance

2
推荐指数
1
解决办法
243
查看次数