Пример #1
0
        private void Main()
        {
            using (IdentityScope c = new IdentityScope(@"\\172.0.0.1\test\", "userName", "password"))
            {//在此就可以访问了.
                //string dateFolder = @"\\127.0.0.1\test\";
                //if (!Directory.Exists(dateFolder))
                //    Directory.CreateDirectory(dateFolder);
                string             filePath = @"\\127.0.0.1\test\test.DB";
                System.IO.FileInfo file     = new System.IO.FileInfo(filePath);
                if (file.Exists)
                {
                    HttpContext.Current.Response.Clear();

                    HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
                    HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
                    HttpContext.Current.Response.ContentType = "application/octet-stream";
                    HttpContext.Current.Response.Filter.Close();

                    HttpContext.Current.Response.WriteFile(file.FullName);
                    HttpContext.Current.Response.End();
                }
            }
        }
Пример #2
0
        private void Main()
        {
            using (IdentityScope c = new IdentityScope(@"\\172.0.0.1\test\", "userName", "password"))
            {//在此就可以访问了.

                //string dateFolder = @"\\127.0.0.1\test\";
                //if (!Directory.Exists(dateFolder))
                //    Directory.CreateDirectory(dateFolder);
                string filePath = @"\\127.0.0.1\test\test.DB";
                System.IO.FileInfo file = new System.IO.FileInfo(filePath);
                if (file.Exists)
                {
                    HttpContext.Current.Response.Clear();

                    HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
                    HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
                    HttpContext.Current.Response.ContentType = "application/octet-stream";
                    HttpContext.Current.Response.Filter.Close();

                    HttpContext.Current.Response.WriteFile(file.FullName);
                    HttpContext.Current.Response.End();
                }
            }
        }