Search Options
close
Search the following clips:
All Clips
Everyone's Clips
My Guides
Sign Up
Install
Learn More
Login
如何把网络共享目录映射为本地驱动器(续)
neoit
follow
0
7-10-2009 12:00 AM
148 views
tags:
c#
Add a Comment
Login
to Comment. Not a member yet?
Sign up
Today's Top Clips
Merry Christmas One and All
"Was it good for you?" "Are you kidding?"
Most Unusual Relationships
Ever wondered what sex does to a mans brain? Wonder no more!
Cats Meow - for people only
Have you ever wondered what hope looks like? Meet Celeste Fleck
Polar Bears
Blind Mother regains her sight and sees youngest daughter for the first time
Faithful Dog Rides and Walks Beside Boy's Casket.
Mega Shrooms!
visit the
Top Clips page
View the Top Clips from
July 10, 2009
Embed This Clip In Your Site...
<div style="margin: 12px 0px; font-family: arial; color: #333333; background: #ffffff; border: solid 4px #e5e5e5; width: 100%; clear: left;"><div class="CM_CTB_Content_Wrap" style="margin: 0px; padding: 0px;background-color: #ffffff;"><div style="border-bottom: solid 1px #dcdcdc; white-space: nowrap; margin-bottom: 8px; background-color: #eeeeee ;background-image: url(http://clipmarks.com/images/source-bg.gif); background-repeat: repeat-x; height: 24px; line-height: 24px; vertical-align: middle; padding-bottom: 4px; color: #666666; font-size: 10px;" ><a href="http://clipmarks.com/clip-to-blog/" title="see clips that are hot right now"><img src="http://content.clipmarks.com/blog_embed/3adbcd07-6d5e-4103-8dd3-4d1bce690a01/0150EB1C-2430-4352-B448-336537C30DF1/" alt="" width="19" height="19" border="0" style="vertical-align: middle; margin: 0px 4px; display: inline; border: none; float:none;" /></a>clipped from <a title="http://blog.csdn.net/Knight94/archive/2006/03/31/645367.aspx" href="http://blog.csdn.net/Knight94/archive/2006/03/31/645367.aspx" style="font-size: 11px;">blog.csdn.net</a></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://blog.csdn.net/Knight94/archive/2006/03/31/645367.aspx"><H1 class="title_txt"><IMG width="15" height="16" border="0" alt="原创" src="http://hi.images.csdn.net/images/blog/authorship.gif" /> 如何把网络共享目录映射为本地驱动器(续)<CITE class="fav_csdnstylebykimi"><A title="收藏到我的网摘中,并分享给我的朋友" class="fav_csdnstylebykimi" href="JavaScript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(saveit=window.open('http://wz.csdn.net/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'saveit','scrollbars=no,width=590,height=300,left=75,top=20,status=no,resizable=yes'));saveit.focus();">收藏</A></CITE></H1></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://blog.csdn.net/Knight94/archive/2006/03/31/645367.aspx"><P class="MsoNormal"><FONT size="3"><SPAN>有人对原来写的那篇文章提出了更深的问题,就是在不知道网络驱动器盘符的情况下,如何进行删除。起始要获得驱动器的盘符也不是件很复杂的事情,只要向</SPAN><SPAN lang="EN-US"><FONT face="Times New Roman">WMI</FONT></SPAN><SPAN>进行查询即可,大致的方法如下。</SPAN></FONT></p> <P class="MsoNormal"><SPAN lang="EN-US"><O:P><FONT face="Times New Roman" size="3"> </FONT></O:P></SPAN></p> <P class="MsoNormal"><FONT size="3"><SPAN>首先,要在工程中引用</SPAN><SPAN lang="EN-US"><FONT face="Times New Roman">Windows.Management</FONT></SPAN><SPAN>。</SPAN></FONT></p> <P class="MsoNormal"><SPAN lang="EN-US"><O:P><FONT face="Times New Roman" size="3"> </FONT></O:P></SPAN></p> <P class="MsoNormal"><FONT size="3"><SPAN>然后,就是用</SPAN><SPAN lang="EN-US"><FONT face="Times New Roman">WMI</FONT></SPAN><SPAN>进行查询,代码如下:</SPAN></FONT></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN><SPAN>public</SPAN> <SPAN>enum</SPAN> DRIVE_TYPE:<SPAN>int<O:P></O:P></SPAN></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN>{<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN>REMOVABLE<SPAN> </SPAN>= 2,<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN>LOCALDISK<SPAN> </SPAN>= 3,<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN>NETDRIVE<SPAN> </SPAN><SPAN> </SPAN>= 4,<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN>CDROM<SPAN> </SPAN><SPAN> </SPAN>= 5,<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN>}<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><O:P> </O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN><SPAN>public</SPAN> ArrayList GetAllNetDriveName()<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN>{<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN><SPAN>//get drive collection<O:P></O:P></SPAN></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN><SPAN>string</SPAN> strQuery = <SPAN>string</SPAN>.Format( "SELECT * From Win32_LogicalDisk WHERE DriveType = {0}", (<SPAN>int</SPAN>)( DRIVE_TYPE.NETDRIVE) );<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><O:P> </O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN>ManagementObjectSearcher query = <SPAN>new</SPAN> ManagementObjectSearcher(strQuery);<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN>ManagementObjectCollection queryCollection = query.Get();<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><O:P> </O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN>ArrayList arrNetDriveName = <SPAN>new</SPAN> ArrayList();<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN><SPAN>foreach</SPAN> ( ManagementObject mo <SPAN>in</SPAN> queryCollection)<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN>arrNetDriveName.Add( mo["Name"].ToString() );<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN><SPAN>return</SPAN> arrNetDriveName;<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><SPAN> </SPAN>}<O:P></O:P></SPAN></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><O:P><FONT face="Times New Roman" size="3"> </FONT></O:P></SPAN></p> <P align="left" class="MsoNormal"><FONT size="3"><SPAN lang="EN-US"><SPAN><FONT face="Times New Roman"> </FONT></SPAN></SPAN><SPAN>网络驱动器的盘符已经获得,那么删除,就可以调用原来的方法,参见:</SPAN></FONT></p> <P align="left" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Times New Roman" size="3">http://blog.csdn.net/knight94/archive/2006/03/21/631309.aspx</FONT></SPAN></P></blockquote></div><div style="margin: 0px 6px 6px 4px;"><table style="font-size: 11px;border-spacing: 0px;padding: 0px;" cellpadding="0" cellspacing="0" width="100%"><tr><td style="background:transparent;border-width:0px;padding:0px;"> </td><td align="right" style="background:transparent;border-width:0px;padding:0px;width:107px" width="107"><a href="http://clipmarks.com/share/0150EB1C-2430-4352-B448-336537C30DF1/blog/" title="blog or email this clip"><img src="http://content6.clipmarks.com/images/c2b-foot.png" border="0" alt="blog it" width="107" height="17" style="border-width:0px;padding:0px;margin:0px;" /></a></td></tr></table></div></div>
New from the makers of Clipmarks:
Amplify.com - Don't just share the news...Amplify it!
Clipmarks
Home
New Clips
Top Clips
Dashboard
Popular Topics
News
Life
Science
Technology
Entertainment
Get Started
Sign Up
Install Clipping Tool
How Clipping Works
Clip-to-Blog™
ClipSearch
Tools and Resources
FAQ
ClipWeek
Top Clippers
Top Tags
Site Map
About Clipmarks
About Us
Contact
Copyright
Privacy
EULA
OK