如何搜索服务器中的文件,服务器有用户名和密码? [英] How to Search a file in a server, which the server have user name and password?

查看:95
本文介绍了如何搜索服务器中的文件,服务器有用户名和密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友,



这里我有一个问题,我需要从服务器搜索文件,但服务器有用户名和密码。它如何在C#源代码中添加用户名和密码。下面的程序是我为搜索文件做的,但是当我编译时它有错误,显示指定的服务器无法执行请求的操作。服务器用户名= user,密码= user123。请帮帮我......



<前lang =cs> 受保护 void Button2_Click( object sender,EventArgs e)
{
ListBox1.Items.Clear();
string search = TextBox1.Text;
if (TextBox1.Text!=
{
string [] \\ text = new < span class =code-keyword> string [] { 。pdf 。PDF};
var pdffiles = Directory.GetFiles( @ \\192.118.0.18 \documents * + TextBox1 .Text + *。*,SearchOption.AllDirectories)。其中(s = > ext.Any(n = > s.EndsWith(n)));

IComparer mycomparer = new myReverserClass();
string [] sarray = pdffiles.ToArray();

DateTime [] creationtime = new DateTime [sarray.Length];
for int i = 0 ; i < sarray.Length; i ++)
creationtime [i] = new 的FileInfo(sarray [I])CREATIONTIME。
Array.Sort(creationtime,sarray,mycomparer);

foreach string file in sarray)
{
ListBox1.Items.Add( new ListItem(Path.GetFileName(file),file));
}
{
TextBox1.Text = ;
}
}
else
{
Response.Write( < script> alert('请输入搜索关键字');< / script>);
}
}

解决方案

想法



a)让sys管理员在服务器上创建一个包含'everyone rights'的公共共享,并将文件放在那里



b)让sys admin创建文件所在的服务器上的私人共享,并为您的帐户授予权限,然后将共享从您的工作机器永久映射到服务器的私人共享



c让sys管理员授予您对服务器上驱动器的权限,并将网络共享动态地映射到您的计算机上 - 这样可以提供您所需要的内容 http://www.codeguru.com/csharp/csharp/cs_network/windowsservices/article.php/c12357 /C-Map-Network-Drive-API.htm [ ^ ]



d)以其他方式获取文件从服务器ftp,ftps,webdav,scp .....并在本地使用它们


Hi Friends,

Here i have a problem which is, i need to search a file from a server, but the server is have user name and password. How could it add the user name and password in the C# source code. Below program were i m do for search files, but when i compile it have error, which shows "The specified server cannot perform the requested operation". The server user name = user, password=user123. Please help me...

protected void Button2_Click(object sender, EventArgs e)
        {
            ListBox1.Items.Clear();
            string search = TextBox1.Text;
            if (TextBox1.Text != "")
            {
                string[] ext = new string[] { ".pdf", ".PDF" };
                var pdffiles = Directory.GetFiles(@"\\192.118.0.18\documents", "*" + TextBox1.Text + "*.*", SearchOption.AllDirectories).Where(s => ext.Any(n => s.EndsWith(n)));

                IComparer mycomparer = new myReverserClass();
                string[] sarray = pdffiles.ToArray();

                DateTime[] creationtime = new DateTime[sarray.Length];
                for (int i = 0; i < sarray.Length; i++)
                    creationtime[i] = new FileInfo(sarray[i]).CreationTime;
                Array.Sort(creationtime, sarray, mycomparer);

                foreach (string file in sarray)
                {
                    ListBox1.Items.Add(new ListItem(Path.GetFileName(file), file));
                }
                {
                    TextBox1.Text = "";
                }
            }
            else
            {
                Response.Write("<script>alert('Please Enter Search Keyword');</script>");
            }
}

解决方案

thoughts

a) have the sys admin create a public share with 'everyone rights' on the server, and have the file(s) put there

b) have the sys admin create a private share on the server where the files are and give your account permissions to it, then permanently map a share from your work machine to the server 'private' share

c) have the sys admin give you rights to the drive on the server, and map a network share to your machine 'dynamically' - this gives the guts of what you need http://www.codeguru.com/csharp/csharp/cs_network/windowsservices/article.php/c12357/C-Map-Network-Drive-API.htm[^]

d) get the file(s) some other way from the server ftp, ftps, webdav, scp ..... and use them locally


这篇关于如何搜索服务器中的文件,服务器有用户名和密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆