我试图在ASP .NET应用程序中使用WebBrowser控件:
public BrowserForm()
{
webBrowser1 = new WebBrowser();
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
private void webBrowser1_DocumentCompleted(Object sender, WebBrowserDocumentCompletedEventArgs e)
{
// code here
}
Run Code Online (Sandbox Code Playgroud)
但得到错误:
'8856f961-340a-11d0-a96b-00c04fd705a2'无法实例化,因为当前线程不在单线程单元中
然后我做了这样的事情:
public BrowserForm()
{
ThreadStart ts = new ThreadStart(StartThread);
var t = new Thread(ts);
t.SetApartmentState(ApartmentState.STA);
t.Start();
}
[STAThread]
public void StartThread()
{
webBrowser1 = new WebBrowser();
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
[STAThread]
private void webBrowser1_DocumentCompleted(Object sender, WebBrowserDocumentCompletedEventArgs e)
{
//code here
}
Run Code Online (Sandbox Code Playgroud)
但仍然没有按照我的意愿为我工作......给我一些错误的错误:
错误HRESULT E_FAIL已从调用COM组件返回
任何工作?我不是线程或COM的专家,但是尝试将WindowApplication转换为WebApplication,它使用网页的屏幕截图提供了一个URL.:(
是否可能"无论如何"我可以在Mono项目中使用Linq到SQl?如果它实际上是.net端口,那么如果我导入System.data.Linq和VS中生成的DBML,它会工作吗?
谢谢!
我必须创建一个接口以上传最大30MB的大型视频,然后将其流式传输并将其转换为FLV格式,然后在浏览器中播放...这在我的网站的“视频库”模块中是必需的。我的Web应用程序在C#和ASP.NET中。我也可以使用jQuery。
我必须分批发送视频文件,然后在服务器上将其合并,流式传输,为视频创建缩略图然后播放。
如果有人请给我解决方案。
最终,我得到了以代码块形式上传视频文件的代码……但是请帮助我做进一步的处理,例如创建缩略图并在浏览器中显示视频。
这是用于分批上传视频的代码。
点击上传按钮
protected void btnUploadVideo_Click(object sender, EventArgs e)
{
UploadVideoFile obj = new UploadVideoFile();
string FileName = fuUploadVideo.FileName;
string DestPath = Server.MapPath("Videos");
string strFinalFileName = Path.GetFileName(fuUploadVideo.FileName);
long FileLength = fuUploadVideo.PostedFile.ContentLength;
long uploadchunklimit;
int SizeLimit = (int)FileLength;
if (FileLength <= 1024)
{
uploadchunklimit = 1;
SizeLimit = (int)FileLength;
}
else if (FileLength > 10240)
{
uploadchunklimit = FileLength / 10240;
SizeLimit = 10;
}
else if (FileLength <= 10240 && FileLength > 1024)
{
uploadchunklimit = …Run Code Online (Sandbox Code Playgroud) 我试图从specipic位置删除excel文件.但不能删除.有错误:
访问路径'C:\ mypath\sample.xlsx'被拒绝.
我写了一个代码:
protected void imgbtnImport_Click(object sender, ImageClickEventArgs e)
{
try
{
string strApplicationPath = HttpContext.Current.Request.MapPath(HttpContext.Current.Request.ApplicationPath);
string strXLStoredDirectoryPath = strApplicationPath + "/Information Documents/";
DirectoryInfo di = new DirectoryInfo(strXLStoredDirectoryPath);
string fileName = flUpldSelectFile.FileName;
if (!File.Exists(strXLStoredDirectoryPath))
{
Directory.CreateDirectory(strXLStoredDirectoryPath);
di.Attributes = FileAttributes.Normal;
}
string strCreateXLFileDestinationPath = strXLStoredDirectoryPath + fileName;
if (File.Exists(strCreateXLFileDestinationPath))
{
File.Delete(strCreateXLFileDestinationPath);
}
flUpldSelectFile.SaveAs(strCreateXLFileDestinationPath);
di.Attributes = FileAttributes.ReadOnly;
}
catch (Exception)
{
throw;
}
}
Run Code Online (Sandbox Code Playgroud)
请指导.........
- *****************************************那里还有问题.它没有解决.获取UnauthorizedAccessException.因访问被拒绝删除文件.我现在累了.请帮忙; 我尝试了很多东西..请帮忙 - *******************************************************************VSS可能是否有效?我正在使用它
for (int i = 0; i < X; i++)
myitem = (checkedDB) ? dirtyItem : cleanItem;
Run Code Online (Sandbox Code Playgroud)
我想知道是否有一种在同一语句中翻转checkedDB的方法,即下一次迭代checkedDB与它的值相反,所以就像XORing一样.