当我在控制台应用程序中执行以下代码时,我得到"进程不能是文件X,因为它正被另一个进程使用":
List<string> lines1 = new List<string>();
List<string> lines2 = new List<string>();
string path1 = ConfigurationManager.AppSettings.Get("path1");
string path2 = ConfigurationManager.AppSettings.Get("path2");
File.Create(path1);
File.Create(path2);
foreach (object myObject in myObjects)
{
//do some fancy logic here!!!
}
File.WriteAllLines(path1, lines1.ToArray()); //exception is thrown here
File.WriteAllLines(path2, lines2.ToArray());
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
我正在开发一个SSIS包,它将打开Excel电子表格并将数据导入SQL Server 2008中的数据库表.当我尝试将Excel列数据类型转换Unicode String [DT_WSTR]为唯一标识符数据类型:时unique identifier [DT_GUID],我收到以下错误:
"转换规范的字符值无效"
我需要做些什么来解决转换错误?
我的页面引用了一个CSS样式表,其定义如下:
html {background-color:#FFFFFF;background-image:url('../images/Background.png');background-repeat:repeat-x; }
Run Code Online (Sandbox Code Playgroud)
如何background-image在页面级别覆盖元素?我需要在我的应用程序中覆盖一个页面的设置.
我有以下未排序的列表:
List<string> myUnsortedList = New List<string>();
myUnsortedList.Add("Alpha");
myUnsortedList.Add("(avg) Alpha");
myUnsortedList.Add("Zeta");
myUnsortedList.Add("Beta");
myUnsortedList.Add("(avg) Beta");
myUnsortedList.Add("(avg) Zeta");
Run Code Online (Sandbox Code Playgroud)
我想按字母顺序降序排序,然后在正常值之后使用(avg)值:
最终结果:Zeta,(平均)Zeta,Beta,(平均)Beta,Alpha,(平均)Alpha
我的应用程序是写的C#,我想用它LINQ来完成排序
我有以下事件日志查询,需要按事件 ID 和创建时间的特定日期范围进行筛选。这是我目前拥有的:
var _PRINTINGDOCUMENTEVENTID = "307";
var startTime = System.DateTime.Now.AddMinutes(-10);
var endTime = System.DateTime.Now
var query = string.Format("*[[System/EventID={0}] and [System[TimeCreated[@SystemTime >= {1}]]] and [System[TimeCreated[@SystemTime <= {2}]]]", _PRINTINGDOCUMENTEVENTID, startTime.ToUniversalTime().ToString("o"), endTime.ToUniversalTime().ToString("o"));)
var logQuery = new EventLogQuery("Microsoft-Windows-PrintService/Operational", PathType.LogName, query );
var reader = new EventLogReader(logQuery);
Run Code Online (Sandbox Code Playgroud)
当我尝试调试事件日志查询时出现以下错误:
指定的查询无效
这是query调试时该值的样子:
“*[[System/EventID=307] 和 [System[TimeCreated[@SystemTime >= 2016-03-28T22:51:23.9082575Z]]] 和 [System[TimeCreated[@SystemTime <= 2016-03-28T23:01] :23.9092576Z]]]"
我该如何解决这个问题?
当我使用columns属性来确定ASP.NET文本框控件的宽度时,一列的确切像素大小是多少?
<asp:TextBox id="MyTextBox" runat="server" columns="10" />
Run Code Online (Sandbox Code Playgroud) 有没有办法在子页面中确定后面的代码是由父页面的window.open()javascript命令打开的?
弹出页面包含一个用户控件,该控件由未从window.open()命令生成的其他页面使用,我想在用户在子页面中完成任务后动态添加关闭页面的功能.
它是一个ASP.NET C#3.5应用程序.
我可以使用System.Reflection在另一个独立的aspx页面中加载一个独立的aspx页面吗?
我正在使用ASP.NET 2.0网站项目模型.
我如何找到IIS虚拟目录的.NET框架正在C#中使用.我需要将它显示给用户.
using System.DirectoryServices;
using System.IO;
private enum IISVersion
{
IIS5,
IIS6
}
private void ReadVirtualDirectory(string server, string directory, IISVersion version)
{
string siteID = string.Empty;
string path = string.Empty;
switch(verison)
{
case IISVersion.IIS5:
path = string.Format("IIS://{0}/W3SVC/1/Root", server);
if(!string.IsNullOrEmpty(directory))
{
path = string.Concat(path, "/", directory);
}
break;
case IISVersion.IIS6:
path = string.Format("IIS://{0}/W3SVC", server);
if(!string.IsNullOrEmpty(directory))
{
DirectoryEntry de = new DirectoryEntry(path);
foreach(DirectoryEntry child in de.Children)
{
if(child.Properties["ServerComment"].Value.ToString().ToLower() == directory)
{
siteID = child.Name;
break;
}
}
path = string.Concat(path, "/", siteID);
de.Close() …Run Code Online (Sandbox Code Playgroud) 我有一个Web用户控件,在客户端上生成以下html.
我想使用JavaScript引用特定的RadioButton控件.
我不知道如何做到这一点因为asp.net生成了RadioButton ID.
例如,我给出RadioButton ID = 1_RadioButton
asp.net生成一个ID = ctl00_ContentPlaceHolder1_Material_1_RadioButton
这个javascript代码怎么能找到Radio Button控件?
<script type="text/javascript">
$(document).ready(function() {
if (document.getElementById("1_RadioButton").checked) {
$("#1_other").hide();
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
以下是asp.net为客户端生成的内容.
<input id="ctl00_ContentPlaceHolder1_Material_1_RadioButton" type="radio" name="ctl00$ContentPlaceHolder1$Material$Academic" value="1_RadioButton" onclick="javascript:$('#1_other').show('fast');" />
<label for="ctl00_ContentPlaceHolder1_Material_1_RadioButton">Yes</label>
<input id="ctl00_ContentPlaceHolder1_Material_2_RadioButton" type="radio" name="ctl00$ContentPlaceHolder1$Material$Academic" value="2_RadioButton" checked="checked" onclick="javascript:$('#1_other').hide('fast');" />
<label for="ctl00_ContentPlaceHolder1_Material_2_RadioButton">No</label>
<input id="ctl00_ContentPlaceHolder1_Material_3_RadioButton" type="radio" name="ctl00$ContentPlaceHolder1$Material$Academic" value="3_RadioButton" onclick="javascript:$('#1_other').hide('fast');" />
<label for="ctl00_ContentPlaceHolder1_Material_3_RadioButton">Uncertain</label>
<div id='1_other'>
<input name="ctl00$ContentPlaceHolder1$Material$4_TextBox" type="text" value="bbb chabng" id="ctl00_ContentPlaceHolder1_Material_4_TextBox" />
</div>
Run Code Online (Sandbox Code Playgroud)