亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Deleting Directory in ASP.net 2.0

系統(tǒng) 2629 0

http://www.vikramlakhotia.com/Deleting_Directory_in_ASPnet_20.aspx

Have you tried to delete a directory programmatically in ASP.Net 2.0? Don’t try it; it can cause great problems to your site especially if you are using in-proc session. You will lose the entire session variable after deleting the directory and there is no way of getting those session variable back. This system is a change from asp.net 1.X.

I came to know about this the hard way. I was working on a project were project submission was a process of 6 pages (All in one page using the MultiView control). In the last stem I was supposed to delete the entire directory which was created during the process. Strangely I was loosing all the session values when the directories were deleted.

The problem gets bigger from the fact that the AppDomain will restart again on the first request to that application. So there is no way to restore the session after deleting the directory in the application domain. There is no problem in creating the directory but deleting will hurt the in-proc session.

What we can do not delete the folder and only delete the files in the folder. I.e. instead of

Directory.Delete(Server.MapPath(path), true);

Use

filedelete(Server.MapPath(path));

where filedelete() is, (I prefer creating these utilities into function so that I do not write the same code again and again)

private void filedelete(string path)
{
??? ??? string[] st;
??????? st = Directory.GetFiles(path);
??????? int i;
??????? for (i = 0; i < st.Length; i++)
??????? {
??????????? try
??????????? {
??????????????? File.Delete(st.GetValue(i).ToString());
??????????? }
??????????? catch { }
??????? }
? ? }

I never thought this File Change Notifications (FCN) can cause me so much of problem. So if you find yourself working with file system in DOT Net. Remember deleting a directory can be more than dangerous. So try not to delete any directory at the runtime.

Deleting Directory in ASP.net 2.0


更多文章、技術交流、商務合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 欧美 日韩 中文字幕 | 国产一区二区三区乱码网站 | 老司机午夜永久在线观看 | 亚洲欧美色综合一区二区在线 | 四虎最新紧急入口4hu | 久久精品国产精品亚洲精品 | 色天使色婷婷在线影院亚洲 | 欧美精品v欧洲高清 | 久久性视频 | 国产久热精品 | 青草久草 | 欧美洲大黑香蕉在线视频 | 国产美女久久精品香蕉69 | 久久精品综合 | 欧洲一级 | 欧美精品大片 | 午夜剧j | 国产精品久久现线拍久青草 | 老妇毛片| 一级特黄a视频 | 久久久这里只有精品免费 | 欧美一级毛片香蕉网 | 亚洲色无码播放 | 色综合久久夜色精品国产 | 综合久久国产对白 | 日本一级作爱片在线观看 | 热99久久| 99国产在线播放 | 久久综合九九亚洲一区 | 国产资源福利 | 两性影院 | 激情综合五月婷婷 | 日韩 亚洲 欧美 中文 高清 | 久久精品国产只有精品6 | 久久加勒比 | 亚洲成人在线免费观看 | 国产成人啪一区二区 | 亚洲精品视频二区 | 久久久久久全国免费观看 | 久久天天躁夜夜躁狠狠85麻豆 | 亚洲国产第一区二区香蕉 |