有没有办法从C#应用程序中以编程方式下载Windows更新?我想在我的应用程序中管理更新的安装.
我有一个可以显示或隐藏的详细信息面板.
如何显示/隐藏该面板(当然还有其内容)的简单淡入淡出效果?
我正在使用Windows窗体,并且控件opacity
在Windows窗体中没有属性.
我已经创建了一个测试ASP.Net Web Api,现在我想知道如何在Windows窗体应用程序中将它用作Web服务?
当前URL是http://localhost:59682
,当我添加http://localhost:59682
或http://localhost:59682/api/
或http://localhost:59682/api/products/
作为网络服务参考我得到这个错误:There was an error downloading 'http://localhost:59682/api/products/$metadata'.
The request failed with HTTP status 400: Bad Request.
Metadata contains a reference that cannot be resolved: 'http://localhost:59682/api/products/'.
The remote server returned an unexpected response: (405) Method Not Allowed.
The remote server returned an error: (405) Method Not Allowed.
If the service is defined in the current solution, try building the solution and adding the service reference again.
这是我的web.config:
<?xml version="1.0" encoding="utf-8"?> …
Run Code Online (Sandbox Code Playgroud) 我想使用具有一些先决条件的ClickOnce发布我的应用程序(.NET 4.5和SQL Server Express).
我按照如何:在ClickOnce应用程序中包含先决条件(请注意包文件夹位于v8.1A
文件夹而不是v8A
文件夹)中进行了操作,但仍然说它无法找到文件.我已经尝试过Visual Studio 2013和Visual Studio 2015 RC.
要在"先决条件"对话框中启用"从我的应用程序的相同位置下载先决条件",必须将项目"Microsoft .NET Framework 4.5(x86和x64)"的文件"DotNetFX45\dotNetFx45_Full_x86_x64.exe"下载到本地计算机.有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkId=239883.
要在"先决条件"对话框中启用"从我的应用程序的相同位置下载先决条件",必须将项目"SQL Server 2012 Express"的文件"SqlExpress2012\SQLEXPR32_x86_ENU.EXE"下载到本地计算机.有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkId=239883.
要在"先决条件"对话框中启用"从我的应用程序的相同位置下载先决条件",必须将项目"SQL Server 2012 Express"的文件"SqlExpress2012\SQLEXPR_x64_ENU.EXE"下载到本地计算机.有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkId=239883.
要在"先决条件"对话框中启用"从我的应用程序的相同位置下载先决条件",必须为项目"Microsoft .NET Framework 4 Client Profile(x86和x64)和.NET for Update"下载文件"DotNetFX40ClientKB2468871\dotNetFx40_Client_x86_x64.exe".框架4(KB2468871)'到您的本地机器.有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkId=239883.
我正在使用此代码来更改HTML流的href属性.
首先我使用以下代码下载完整的html页面:( URL是网页地址)
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(URL);
HttpWebResponse myHttpWebResponse =
(HttpWebResponse)myHttpWebRequest.GetResponse();
Stream s = myHttpWebResponse.GetResponseStream();
Run Code Online (Sandbox Code Playgroud)
然后我处理这个:
HtmlDocument doc = new HtmlDocument();
doc.Load(s);
foreach (HtmlNode link in doc.DocumentNode.SelectNodes("/a"))
{
string att = link.Attributes["href"].Value;
link.Attributes["href"].Value = "http://ahmadalli.somee.com/default.aspx?url=" + att;
}
doc.Save(s);
Run Code Online (Sandbox Code Playgroud)
s
是HTML流.
但我有一个例外,说doc.DocumentNode
是空的!
我试过很多网站,但是doc.DocumentNode
没有
我想用扩展名显示图像,*.ico
我用Stream
它来做.但我有一个问题.
随着扩展*.jpg
,*.bmp
...图像显示确定,但*.ico
它没有显示
这是我的代码:
private void OutputStream(string fileName)
{
try
{
Stream dataStream = null;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPFile spFile = web.GetFile(fileName);
dataStream = spFile.OpenBinaryStream();
this.HandleOutputStream(dataStream);
});
}
catch (System.Threading.ThreadAbortException exTemp)
{
logger.Error("KBStreamPicture::OutputStream", exTemp);
}
catch (Exception ex)
{
//System.Diagnostics.Debug.Write("OutputStream::" + ex);
logger.Error("KBStreamPicture::OutputStream", ex);
}
}
Run Code Online (Sandbox Code Playgroud)
和
private void HandleOutputStream(Stream dataStream)
{
const int bufferSize = 16384; //16KB
using (Stream file = dataStream)
{
if (file != null)
{
this.Page.Response.Clear();
this.Page.Response.Cache.SetCacheability(System.Web.HttpCacheability.Private);
this.Page.Response.Cache.SetExpires(DateTime.Now.AddMinutes(20)); …
Run Code Online (Sandbox Code Playgroud) 我正在开发一个chrome扩展程序,我想打开一个新选项卡,但是在用户所在的当前选项卡之后.这就是我试图做的事情:
function clickEvent(info, tab) {
update();
var url= "http://google.com";
var id = tab.id+1;
chrome.tabs.create({'url': url, 'index': id});
}
Run Code Online (Sandbox Code Playgroud)
但是创建的选项卡会在chrome选项卡栏中的选项卡队列末尾打开.'index': id
从中删除后chrome.tabs.create
,结果是一样的.我不知道如何解决问题.有谁能够帮我?
我刚刚创建了一个新的MVC 4 Basic项目,并将该软件包添加到项目中,并将所需的代码添加到布局中,但在首次运行后没有任何反应.
这是布局:
@using StackExchange.Profiling;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
@MiniProfiler.RenderIncludes()
@RenderBody()
@Scripts.Render("~/bundles/jquery")
@RenderSection("scripts", required: false)
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
更新
我已将此代码添加到了 global.asax.cs
protected void Application_BeginRequest()
{
MiniProfiler.Start();
}
Run Code Online (Sandbox Code Playgroud)
现在这段代码出现在HTML代码中:
<script async type="text/javascript" id="mini-profiler" src="/mini-profiler-resources/includes.js?v=xwYPDDH1blvqmxgsBweNC++H7CFU3KGQ+zFcVlJPsXw=" data-version="xwYPDDH1blvqmxgsBweNC++H7CFU3KGQ+zFcVlJPsXw=" data-path="/mini-profiler-resources/" data-current-id="6da0f73c-fa89-447b-92b1-56dc532947f4" data-ids="6da0f73c-fa89-447b-92b1-56dc532947f4" data-position="left" data-trivial="false" data-children="false" data-max-traces="15" data-controls="false" data-authorized="true" data-toggle-shortcut="Alt+P" data-start-hidden="false"></script>
Run Code Online (Sandbox Code Playgroud)
但是/mini-profiler-resources/includes.js?v=xwYPDDH1blvqmxgsBweNC++H7CFU3KGQ+zFcVlJPsXw=
url返回404错误.
我有一个程序可以将文件或文件夹重命名为小写名称。我写了这段代码:
private void Replace(string FolderLocation, string lastText, string NewText)
{
if (lastText == "")
{
lastText = " ";
}
if (NewText == "")
{
NewText = " ";
}
DirectoryInfo i = new DirectoryInfo(FolderLocation);
string NewName = "";
if (checkBox2.Checked)
{
if (i.Parent.FullName[i.Parent.FullName.Length - 1].ToString() != "\\") //For parents like E:/
{
NewName = i.Parent.FullName + "\\" + i.Name.Replace(lastText, NewText);
}
else
{
NewName = i.Parent.FullName + i.Name.Replace(lastText, NewText);
}
NewName = NewName.ToLower();
if (NewName != i.FullName)
{
i.MoveTo(NewName); …
Run Code Online (Sandbox Code Playgroud) c# ×9
asp.net ×4
.net ×3
c#-4.0 ×3
.net-3.5 ×1
asp.net-mvc ×1
clickonce ×1
content-type ×1
file-rename ×1
fileinfo ×1
stream ×1
web-services ×1
windows ×1
winforms ×1