Mkdir() public method

public Mkdir ( string directory ) : void
directory string
return void
Esempio n. 1
0
        public static bool image_01_FileMake(string filePath)
        {
            Boolean bResult;
            string _sftpHost = "ledev.leisureq.co.kr";
            string _sftpUserId = "lion";
            string _sftpUserPw = "gkffl1!";
            Int32 _sftpPort = 10004;

            string[] path = filePath.Split(new char[] { '/' });

            try
            {
                string ppath = "";
                Sftp sftp = new Tamir.SharpSsh.Sftp(_sftpHost, _sftpUserId, _sftpUserPw);
                sftp.Connect(_sftpPort);

                for (int i = 1; i < path.Length; i++)
                {
                    ppath = ppath + "/" + path[i];
                    ArrayList res = sftp.GetFileList(ppath);
                    string checkFile = path[i+1];

                    if (res.IndexOf(checkFile) == -1)
                    {
                        sftp.Mkdir(ppath + "/" + checkFile);
                    }

                }

                bResult = true;
            }
            catch (SystemException ex)
            {
                NewLogManager2.Instance.Log(string.Format("Error image_01_FileMake {0}", ex.Message));
                bResult = false;
            }

            return bResult;
        }
Esempio n. 2
0
        public static bool image_01_FileMake(string filePath)
        {
            Boolean bResult;
            string  _sftpHost   = "ledev.leisureq.co.kr";
            string  _sftpUserId = "lion";
            string  _sftpUserPw = "gkffl1!";
            Int32   _sftpPort   = 10004;

            string[] path = filePath.Split(new char[] { '/' });

            try
            {
                string ppath = "";
                Sftp   sftp  = new Tamir.SharpSsh.Sftp(_sftpHost, _sftpUserId, _sftpUserPw);
                sftp.Connect(_sftpPort);

                for (int i = 1; i < path.Length; i++)
                {
                    ppath = ppath + "/" + path[i];
                    ArrayList res       = sftp.GetFileList(ppath);
                    string    checkFile = path[i + 1];

                    if (res.IndexOf(checkFile) == -1)
                    {
                        sftp.Mkdir(ppath + "/" + checkFile);
                    }
                }

                bResult = true;
            }
            catch (SystemException ex)
            {
                NewLogManager2.Instance.Log(string.Format("Error image_01_FileMake {0}", ex.Message));
                bResult = false;
            }

            return(bResult);
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string makefile = HKLibrary.UTIL.HKFileHelper.GetCurrentDirectory();
            string sDirPath;

            sDirPath = makefile + "\\data";
            DirectoryInfo di = new DirectoryInfo(sDirPath);

            if (di.Exists == false)
            {
                di.Create();
            }

            string PinCode = "41302903000002";

            makefile = makefile + "\\data\\" + PinCode + ".png";
            Int32 OrderSeq = 406359;

            string folderName  = Convert.ToString(OrderSeq);
            string ftpfileName = folderName + "/" + PinCode + ".jpg";

            string ftpBasicPath = "/var/www/IMAGE/Web/upload/order/barcode";
            //string ftpBasicPath = "/var/www/IMAGE/Web/upload/order/qrcode/";

            QrEncoder    qrEncoder = new QrEncoder(ErrorCorrectionLevel.M);
            QrCode       qrCode    = qrEncoder.Encode(PinCode);
            var          renderer  = new GraphicsRenderer(new FixedCodeSize(400, QuietZoneModules.Zero), Brushes.Black, Brushes.White);
            MemoryStream ms        = new MemoryStream();

            renderer.WriteToStream(qrCode.Matrix, ImageFormat.Png, ms);
            var image = new Bitmap(Image.FromStream(ms), new Size(new Point(200, 200)));

            image.Save(makefile, ImageFormat.Png);
            Tamir.SharpSsh.Sftp sftp;

            sftp = new Tamir.SharpSsh.Sftp("ledev.leisureq.co.kr", "lion", "gkffl1!");
            sftp.Connect(10004);
            ArrayList res = sftp.GetFileList("/");

            sftp.Mkdir(ftpBasicPath + "/" + folderName + "/");
            sftp.Put(makefile, ftpBasicPath + "/" + ftpfileName);
            sftp.Close();


            //BarcodeLib.Barcode b = new BarcodeLib.Barcode();
            //b.Encode(BarcodeLib.TYPE.CODE128, PinCode);
            //b.SaveImage(makefile, BarcodeLib.SaveTypes.JPG);

            /*
             * string date = "2015-05-20 17:16:44";
             * string[] datePartPath = new string[4];
             *
             * DateTime dt = Convert.ToDateTime(date);
             * datePartPath[0] = dt.ToString("yyyy");
             * datePartPath[1] = dt.ToString("MM");
             * datePartPath[2] = dt.ToString("dd");
             * datePartPath[3] = Convert.ToString(OrderSeq);
             *
             *
             * for(Int32 i =0; i<datePartPath.Length; i++){
             *  ftpBasicPath = ftpBasicPath + "/" + datePartPath[i];
             * }
             * comwls.image_01_FileMake(ftpBasicPath);
             *
             */
            string ftpUri = "sftp://ledev.leisureq.co.kr:10004/" + ftpBasicPath + folderName;

            HKLibrary.comwls.comwls.image_01_FileMake(ftpBasicPath + folderName);

            FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpUri);

            request.Method = WebRequestMethods.Ftp.MakeDirectory;
            //request.Method = WebRequestMethods.Ftp.UploadFile;

            // This example assumes the FTP site uses anonymous logon.
            request.Credentials = new NetworkCredential("lion", "gkffl1!");
            FtpWebResponse response  = (FtpWebResponse)request.GetResponse();
            Stream         ftpStream = response.GetResponseStream();

            ftpStream.Close();
            response.Close();


            /*
             * string ftpUri = "ftp://121.78.127.40:21/" + ftpBasicPath + folderName;
             *
             * FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpUri);
             * request.Method = WebRequestMethods.Ftp.MakeDirectory;
             *
             * // This example assumes the FTP site uses anonymous logon.
             * request.Credentials = new NetworkCredential("infobay", "info9887");
             * FtpWebResponse response = (FtpWebResponse)request.GetResponse();
             * Stream ftpStream = response.GetResponseStream();
             *
             *   ftpStream.Close();
             *   response.Close();
             *
             *   ftpUri = "ftp://121.78.127.40:21/" + ftpBasicPath + ftpfileName;
             *   request = (FtpWebRequest)WebRequest.Create(ftpUri);
             *   request.Method = WebRequestMethods.Ftp.UploadFile;
             *
             *   // This example assumes the FTP site uses anonymous logon.
             *   request.Credentials = new NetworkCredential("infobay", "info9887");
             *
             *   byte[] fileContents = File.ReadAllBytes(makefile);
             *   request.ContentLength = fileContents.Length;
             *
             *   request.UsePassive = true;
             *   Stream requestStream = request.GetRequestStream();
             *   requestStream.Write(fileContents, 0, fileContents.Length);
             *   requestStream.Close();
             *   response = (FtpWebResponse)request.GetResponse();
             *   response.Close();
             *
             *
             *
             * //sftp.ConnectTimeoutMs = 15000;
             * //sftp.IdleTimeoutMs = 15000;
             *
             * //string hostname = "ftp://ledev.leisureq.co.kr:10004/";
             *
             * //bool success = sftp.Connect(hostname, 10004);
             */
        }
Esempio n. 4
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (theFiles == null)
            {
                MessageBox.Show("Please select a folder");
                return;
            }
            WebClient wc = new WebClient();
            wc.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
            Dictionary<string, string> serverVer = new Dictionary<string, string>();
            wc.Proxy = null;
            try
            {
                string toparse = wc.DownloadString(hashesLoc);

                using (StringReader sr = new StringReader(toparse))
                {
                    string thisLine;
                    while ((thisLine = sr.ReadLine()) != null)
                    {
                        if (thisLine.Contains('|'))
                        {
                            string[] splitted = thisLine.Split('|');
                            serverVer.Add(splitted[0], splitted[1]);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show("Error parsing website, " + ex);
                //return;
                Console.WriteLine("Error parsing website, will overwrite everything.");
            }
            using (StreamWriter fs = new StreamWriter("hashes.html", false))
            {
                foreach (var s in theFiles)
                {
                    fs.WriteLine(s.Key + "|" + s.Value);
                }
            }
            var sftp = new Sftp(hostName.Text, User.Text, pass.Text);
            sftp.OnTransferProgress += new FileTransferEvent(sftp_OnTransferProgress);
            sftp.Connect();
            foreach (var file in theFiles)
            {
                if (serverVer.ContainsKey(file.Key))
                {
                    if (serverVer[file.Key] == file.Value)
                    {
                        Console.WriteLine("skipped " + file.Key);
                        continue;
                    }
                }
                if (file.Key.Contains('\\'))
                {
                    //FileInfo fi = new FileInfo(dirToHash + "\\" + file.Key);
                    //file.Key.Split("");
                    string[] splitted = file.Key.Split('\\');
                    string dirr = root;
                    for (int i = 0; i < splitted.Length - 1; i++)
                    {
                        dirr += splitted[i] + "/";
                        bool mkdir = false;
                        try
                        {
                            sftp.GetFileList(dirr);
                        }
                        catch (Exception)
                        {
                            mkdir = true;
                            Console.WriteLine("Making directory " + dirr);
                        }
                        if (mkdir)
                        {
                            try
                            {

                                sftp.Mkdir(dirr);
                            }
                            catch (Exception exc)
                            {
                                Console.WriteLine("exception with " + dirr + " while making the dir " + exc);
                            }
                        }
                    }

                }
                string changed = file.Key.Replace('\\', '/');
                sftp.Put(dirToHash + "\\" + file.Key, root + changed);
                Console.WriteLine("Sent {0} to {1}", dirToHash + "\\" + file.Key, root + changed);
            }
            sftp.Put("hashes.html", root + "hashes.html");
            Console.WriteLine("Send hashes.html");
            //      foreach (string s in sftp.GetFileList("/"))
            //      {
            //    Console.WriteLine(s);
            //     }
            // sftp.
            //      sftp.Put("test.html","/var/www/test.html");
            sftp.Close();
            /*   FtpWebRequest fRequest = (FtpWebRequest)WebRequest.Create("ftp://proxima-centauri.dreamhost.com/");
               //fRequest.Method = WebRequestMethods.Ftp
               Ftp
               fRequest.Credentials = new NetworkCredential("aevv", "matteh11F");
               Stream ftpStream = fRequest.GetRequestStream();
               */
        }
Esempio n. 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            string makefile = HKLibrary.UTIL.HKFileHelper.GetCurrentDirectory();
            string sDirPath;
            sDirPath = makefile + "\\data";
            DirectoryInfo di = new DirectoryInfo(sDirPath);
            if (di.Exists == false)
            {
                di.Create();
            }

            string PinCode = "41302903000002";
            makefile = makefile + "\\data\\"+PinCode+".png";
            Int32 OrderSeq = 406359;

            string folderName = Convert.ToString(OrderSeq);
            string ftpfileName = folderName + "/" + PinCode + ".jpg";

            string ftpBasicPath = "/var/www/IMAGE/Web/upload/order/barcode";
            //string ftpBasicPath = "/var/www/IMAGE/Web/upload/order/qrcode/";

            QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.M);
            QrCode qrCode = qrEncoder.Encode(PinCode);
            var renderer = new GraphicsRenderer(new FixedCodeSize(400, QuietZoneModules.Zero), Brushes.Black, Brushes.White);
            MemoryStream ms = new MemoryStream();
            renderer.WriteToStream(qrCode.Matrix, ImageFormat.Png, ms);
            var image = new Bitmap(Image.FromStream(ms), new Size(new Point(200, 200)));
            image.Save(makefile, ImageFormat.Png);
            Tamir.SharpSsh.Sftp sftp;

            sftp = new Tamir.SharpSsh.Sftp("ledev.leisureq.co.kr", "lion", "gkffl1!");
            sftp.Connect(10004);
            ArrayList res =  sftp.GetFileList("/");
            sftp.Mkdir(ftpBasicPath + "/" + folderName+ "/");
            sftp.Put(makefile, ftpBasicPath + "/" + ftpfileName);
            sftp.Close();

            //BarcodeLib.Barcode b = new BarcodeLib.Barcode();
            //b.Encode(BarcodeLib.TYPE.CODE128, PinCode);
            //b.SaveImage(makefile, BarcodeLib.SaveTypes.JPG);
            /*
            string date = "2015-05-20 17:16:44";
            string[] datePartPath = new string[4];

            DateTime dt = Convert.ToDateTime(date);
            datePartPath[0] = dt.ToString("yyyy");
            datePartPath[1] = dt.ToString("MM");
            datePartPath[2] = dt.ToString("dd");
            datePartPath[3] = Convert.ToString(OrderSeq);

            for(Int32 i =0; i<datePartPath.Length; i++){
                ftpBasicPath = ftpBasicPath + "/" + datePartPath[i];
            }
            comwls.image_01_FileMake(ftpBasicPath);

            */
            string ftpUri = "sftp://ledev.leisureq.co.kr:10004/"+ ftpBasicPath + folderName;

            HKLibrary.comwls.comwls.image_01_FileMake(ftpBasicPath + folderName);

            FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpUri);
            request.Method = WebRequestMethods.Ftp.MakeDirectory;
            //request.Method = WebRequestMethods.Ftp.UploadFile;

            // This example assumes the FTP site uses anonymous logon.
            request.Credentials = new NetworkCredential("lion", "gkffl1!");
            FtpWebResponse response = (FtpWebResponse)request.GetResponse();
            Stream ftpStream = response.GetResponseStream();

            ftpStream.Close();
            response.Close();

               /*
            string ftpUri = "ftp://121.78.127.40:21/" + ftpBasicPath + folderName;

            FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpUri);
            request.Method = WebRequestMethods.Ftp.MakeDirectory;

            // This example assumes the FTP site uses anonymous logon.
            request.Credentials = new NetworkCredential("infobay", "info9887");
            FtpWebResponse response = (FtpWebResponse)request.GetResponse();
            Stream ftpStream = response.GetResponseStream();

                ftpStream.Close();
                response.Close();

                ftpUri = "ftp://121.78.127.40:21/" + ftpBasicPath + ftpfileName;
                request = (FtpWebRequest)WebRequest.Create(ftpUri);
                request.Method = WebRequestMethods.Ftp.UploadFile;

                // This example assumes the FTP site uses anonymous logon.
                request.Credentials = new NetworkCredential("infobay", "info9887");

                byte[] fileContents = File.ReadAllBytes(makefile);
                request.ContentLength = fileContents.Length;

                request.UsePassive = true;
                Stream requestStream = request.GetRequestStream();
                requestStream.Write(fileContents, 0, fileContents.Length);
                requestStream.Close();
                response = (FtpWebResponse)request.GetResponse();
                response.Close();

            //sftp.ConnectTimeoutMs = 15000;
            //sftp.IdleTimeoutMs = 15000;

            //string hostname = "ftp://ledev.leisureq.co.kr:10004/";

            //bool success = sftp.Connect(hostname, 10004);
            */
        }