真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net打開共享文件 vba訪問共享文件夾

Vb.net 請(qǐng)問如何快速時(shí)時(shí)讀取共享文件夾資料

File.WriteAllText("\\10.1.37.222\shared\temp.txt", "");

十余年的長(zhǎng)嶺網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。網(wǎng)絡(luò)營(yíng)銷推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整長(zhǎng)嶺建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)公司從事“長(zhǎng)嶺網(wǎng)站設(shè)計(jì)”,“長(zhǎng)嶺網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

如果能生成就沒問題。

用VB怎樣打開網(wǎng)絡(luò)上共享的文件(此文件所在目錄加有共享密碼)?

進(jìn)入共享文件夾可以用直接路徑的,不過如果要進(jìn)入共享文件夾下子文件夾里,要先進(jìn)入共享文件夾,然后再過,不然可能會(huì)出現(xiàn)文件查找不到(就算沒有密碼也有可能會(huì)出現(xiàn))例如:進(jìn)入局域網(wǎng)客戶機(jī)PC的共享文件夾basic下子文件夾file里的文件text.txt就要先訪問//pc/basic,寫入密碼,然后再進(jìn)入//pc/basic/file/text.txt

如果不用net use的方法,vb.net 有辦法訪問共享文件或者共享文件夾嗎

我不會(huì)VB,但是都是.net。c#的代碼稍微轉(zhuǎn)換一下就可以了。

C#實(shí)現(xiàn)訪問網(wǎng)絡(luò)共享文件夾,使用?WNetAddConnection2A?和?WNetCancelConnection2A。

在目標(biāo)服務(wù)器建立共享文件夾,建立訪問賬號(hào)test;

public?enum?ERROR_ID

{

ERROR_SUCCESS?=?0,??//?Success?

ERROR_BUSY?=?170,

ERROR_MORE_DATA?=?234,

ERROR_NO_BROWSER_SERVERS_FOUND?=?6118,

ERROR_INVALID_LEVEL?=?124,

ERROR_ACCESS_DENIED?=?5,

ERROR_INVALID_PASSWORD?=?86,

ERROR_INVALID_PARAMETER?=?87,

ERROR_BAD_DEV_TYPE?=?66,

ERROR_NOT_ENOUGH_MEMORY?=?8,

ERROR_NETWORK_BUSY?=?54,

ERROR_BAD_NETPATH?=?53,

ERROR_NO_NETWORK?=?1222,

ERROR_INVALID_HANDLE_STATE?=?1609,

ERROR_EXTENDED_ERROR?=?1208,

ERROR_DEVICE_ALREADY_REMEMBERED?=?1202,

ERROR_NO_NET_OR_BAD_PATH?=?1203

}

public?enum?RESOURCE_SCOPE

{

RESOURCE_CONNECTED?=?1,

RESOURCE_GLOBALNET?=?2,

RESOURCE_REMEMBERED?=?3,

RESOURCE_RECENT?=?4,

RESOURCE_CONTEXT?=?5

}

public?enum?RESOURCE_TYPE

{

RESOURCETYPE_ANY?=?0,

RESOURCETYPE_DISK?=?1,

RESOURCETYPE_PRINT?=?2,

RESOURCETYPE_RESERVED?=?8,

}

public?enum?RESOURCE_USAGE

{

RESOURCEUSAGE_CONNECTABLE?=?1,

RESOURCEUSAGE_CONTAINER?=?2,

RESOURCEUSAGE_NOLOCALDEVICE?=?4,

RESOURCEUSAGE_SIBLING?=?8,

RESOURCEUSAGE_ATTACHED?=?16,

RESOURCEUSAGE_ALL?=?(RESOURCEUSAGE_CONNECTABLE?|?RESOURCEUSAGE_CONTAINER?|?RESOURCEUSAGE_ATTACHED),

}

public?enum?RESOURCE_DISPLAYTYPE

{

RESOURCEDISPLAYTYPE_GENERIC?=?0,

RESOURCEDISPLAYTYPE_DOMAIN?=?1,

RESOURCEDISPLAYTYPE_SERVER?=?2,

RESOURCEDISPLAYTYPE_SHARE?=?3,

RESOURCEDISPLAYTYPE_FILE?=?4,

RESOURCEDISPLAYTYPE_GROUP?=?5,

RESOURCEDISPLAYTYPE_NETWORK?=?6,

RESOURCEDISPLAYTYPE_ROOT?=?7,

RESOURCEDISPLAYTYPE_SHAREADMIN?=?8,

RESOURCEDISPLAYTYPE_DIRECTORY?=?9,

RESOURCEDISPLAYTYPE_TREE?=?10,

RESOURCEDISPLAYTYPE_NDSCONTAINER?=?11

}

[StructLayout(LayoutKind.Sequential)]

public?struct?NETRESOURCE

{

public?RESOURCE_SCOPE?dwScope;

public?RESOURCE_TYPE?dwType;

public?RESOURCE_DISPLAYTYPE?dwDisplayType;

public?RESOURCE_USAGE?dwUsage;

[MarshalAs(UnmanagedType.LPStr)]

public?string?lpLocalName;

[MarshalAs(UnmanagedType.LPStr)]

public?string?lpRemoteName;

[MarshalAs(UnmanagedType.LPStr)]

public?string?lpComment;

[MarshalAs(UnmanagedType.LPStr)]

public?string?lpProvider;

}

public?class?NetworkConnection

{

[DllImport("mpr.dll")]

public?static?extern?int?WNetAddConnection2A?(NETRESOURCE[]?lpNetResource,?string?lpPassword,?string?lpUserName,?int?dwFlags);

[DllImport("mpr.dll")]

public?static?extern?int?WNetCancelConnection2A?(string?sharename,?int?dwFlags,?int?fForce);

public?static?int?Connect?(string?remotePath,?string?localPath,?string?username,?string?password)

{

NETRESOURCE[]?share_driver?=?new?NETRESOURCE[1];

share_driver[0].dwScope?=?RESOURCE_SCOPE.RESOURCE_GLOBALNET;

share_driver[0].dwType?=?RESOURCE_TYPE.RESOURCETYPE_DISK;

share_driver[0].dwDisplayType?=?RESOURCE_DISPLAYTYPE.RESOURCEDISPLAYTYPE_SHARE;

share_driver[0].dwUsage?=?RESOURCE_USAGE.RESOURCEUSAGE_CONNECTABLE;

share_driver[0].lpLocalName?=?localPath;

share_driver[0].lpRemoteName?=?remotePath;

Disconnect(localPath);

int?ret?=?WNetAddConnection2A(share_driver,?password,?username,?1);

return?ret;

}

public?static?int?Disconnect?(string?localpath)

{

return?WNetCancelConnection2A(localpath,?1,?1);

}

調(diào)用方式:

public?static?void?TestNetWorkConnection()

{

string?localpath?=?"X:";

//int?status?=?NetworkConnection.Connect(@"\\192.168.0.2\test",?localpath,?@"test",?"test");

int?status?=?NetworkConnection.Connect("\\\\192.168.0.2\\test",?localpath,?@"test",?"test");

if?(status?==?(int)ERROR_ID.ERROR_SUCCESS)

{

FileStream?fs?=?new?FileStream(localpath?+?@"\\123.txt",?FileMode.OpenOrCreate);

using?(StreamWriter?stream?=?new?StreamWriter(fs))

{

stream.WriteLine("你好呀,成功了");

stream.Flush();

stream.Close();

}

fs.Close();

}

else

{

Console.WriteLine(status);

}

NetworkConnection.Disconnect(localpath);

}


網(wǎng)站標(biāo)題:vb.net打開共享文件 vba訪問共享文件夾
URL網(wǎng)址:http://weahome.cn/article/doshejd.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部