Exemplo n.º 1
0
        private bool CheckFile(HttpPostedFileBase fileUpload)
        {
            if (fileUpload.ContentLength == 0)
            {
                this._uploadtype = UploadUnitType.无文件上传;
                return(false);
            }
            if (fileUpload.ContentLength > UploadLength)
            {
                this._uploadtype = UploadUnitType.文件过大;
                return(false);
            }
            string Files = fileUpload.FileName;

            if (((this._uploadWith.Count > 0) && (this._uploadWith.Count == this._uploadHigth.Count)))
            {
                this._IsThumbnail = true;
            }
            if (!this.CheckExt(Files))
            {
                this._uploadtype = UploadUnitType.文件格式错误;
                return(false);
            }
            this._uploadFileExt = IOFiles.GetExtension(Files).ToLower();
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 读取图片
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static byte[] RedFile(string file)
        {
            var filePath   = IOFiles.GetFileMapPath(file);
            var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            var buffer     = new byte[fileStream.Length];

            fileStream.Read(buffer, 0, buffer.Length);
            fileStream.Close();
            return(buffer);
        }
Exemplo n.º 3
0
 private bool CheckFilePath()
 {
     if (!SafeCheck.IsMap(this._uploadPath))
     {
         this._uploadPath = IOFiles.GetFolderMapPath(this._uploadPath);
     }
     IOFiles.CreatedFolder(this._uploadPath);
     if (IOFiles.IsFolder(this._uploadPath))
     {
         return(true);
     }
     this._uploadtype = UploadUnitType.存储文件夹错误;
     return(false);
 }
Exemplo n.º 4
0
        private string SaveFile(HttpPostedFileBase fileUpload)
        {
            string NewFile = string.Empty;

            try
            {
                string date         = DateTime.Now.Ticks.ToString();
                string filedate     = string.Empty;
                string dateFormat   = DateTime.Now.ToString(this._uploadFormat);
                string datapathyuan = IOFiles.CreatedFolderData(this._uploadPath, dateFormat, out filedate);
                string fileName     = filedate + date + this._uploadFileExt;
                fileUpload.SaveAs(this._uploadPath + fileName);
                this._IsSuccess = true;
                if (this.IsThumbnail)
                {
                    Thumbnail thumbnail = null;
                    if ((this._uploadWith.Count > 0) && (this._uploadHigth.Count > 0))
                    {
                        int count = 0;
                        if (this._uploadWith.Count > this._uploadHigth.Count)
                        {
                            count = this._uploadHigth.Count;
                        }
                        else
                        {
                            count = this._uploadWith.Count;
                        }
                        string resultfile = fileName;
                        for (int i = 0; i < count; i++)
                        {
                            thumbnail = new Thumbnail(this._uploadPath + fileName);
                            NewFile   = string.Concat(new object[] { filedate, date, "_", i, this._uploadFileExt });
                            thumbnail.thumbnailFile(this._uploadPath + NewFile, this._uploadWith[i], this._uploadHigth[i]);
                            if (i == 0)
                            {
                                resultfile = NewFile;
                            }
                        }
                        fileName = resultfile;
                    }
                }
                return(fileName);
            }
            catch
            {
                this._uploadtype = UploadUnitType.保存文件出错;
                return("");
            }
        }
Exemplo n.º 5
0
        void initLocalBase()
        {
            // Проверка файла настроек (конфиг файл)
            if (!File.Exists(Config.resource + "config.cfg"))
            {
                IOFiles.CreateConfigFile();
            }
            IOFiles.ReadConfigFile();

            // Поиск локальной базы данный Database
            Config.databaseFile = Config.resource + "database.mdb";
            if (!File.Exists(Config.databaseFile))
            {
                // файл не найден, он будет создан
                Config.oledbConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
                CreateDatabaseMSAccess createDatabaseMSAccess = new CreateDatabaseMSAccess(Config.databaseFile);
                createDatabaseMSAccess.CreateDB();
            }

            // проверка целосности данных
            if (VerificationDatabaseMSAccess.Verification())
            {
                showClient();
            }
            else
            {
                MessageBox.Show("База данных испорчена, её нужно удалить и перезапустить приложение." + Environment.NewLine + "При следующем запуске будет создана новая база данных.", "Сообщение");
                DialogResult dialogResult = MessageBox.Show("Удалить испорченную базу данных?", "Вопрос", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    if (File.Exists(Config.databaseFile))
                    {
                        File.Delete(Config.databaseFile);
                    }
                }
                Application.Exit();
            }
        }
Exemplo n.º 6
0
        //RAFAPUIG: Mira donde tienes el proyecto ReadFile porque esta fuera del repositorio y no carga
        static void Main(string[] args)
        {
            //ReadFile.IOFiles.file.Close();
            Console.SetWindowSize(105, 50);
            string entrada;
            char   resp;
            char   letra;
            bool   PalabraOK = false; //estado si ha pasado control calidad la palabra introducida
            int    option;
            string palabra;

            //Dibujo.intro_Animado();

            do
            {
                do
                {
                    do
                    {
                        System.Console.Clear();
                        Dibujo.intro_Animado();
                        Dibujo.cabecera();
                        Console.WriteLine("1)Maquina vs jugador\n2)jugador vs jugador");
                        PalabraOK = int.TryParse(Console.ReadLine(), out option);
                    } while (!PalabraOK);
                    PalabraOK = false;
                    switch (option)// segun opcion realizada
                    {
                    case 1:
                        entrada   = IOFiles.RandomWord();  // contra la maquina sacamos palabra al azr del archivo
                        PalabraOK = true;
                        break;

                    case 2:
                        Console.WriteLine("Introduce una palabra a ocultar"); //introducimos palabra manualmente para jugador contra jugador
                        entrada   = Console.ReadLine();
                        PalabraOK = Juego.FiltrarPalabra(entrada);            // validamos palabra
                        IOFiles.AmpliaDiccionario(entrada);                   //y la añadimos al diccionario para una proxima partida

                        break;

                    default:
                        Juego.MensajeError("Error, opcion no valida");
                        entrada   = "";
                        PalabraOK = false;
                        break;
                    }
                } while (!PalabraOK);
                Dibujo.cargando();
                palabra = entrada.ToUpper(); //cogemos ya la palabra en mayusculas

                //Ocultamos palabra para mostrarla ocuulta
                Juego.OcultarPalabra(palabra);
                //recogemos la letra
                Dibujo.dibujo_inicial();


                do//do while principal
                {
                    //este do while se encarga de repetir proceso mientras no me de una entrada correcta
                    do
                    {
                        System.Console.Clear();
                        Dibujo.cabecera(); //dibujamos
                        PalabraOK = true;
                        if (!PalabraOK)
                        {
                            Dibujo.dibujo_inicial();
                        }
                        else
                        {
                            Dibujo.dibujar();                                           //condicion para que dibujo hacer( primera tirada o no)
                        }
                        Dibujo.MarcoContador(Juego.intentos);
                        Console.WriteLine("ADIVINA");
                        //Console.WriteLine(palabra);
                        Console.WriteLine("\n-----------------------------------------");
                        Console.WriteLine("{0}", Juego.hword);
                        Console.WriteLine("-----------------------------------------");

                        Console.Write("Introduce una letra\n->");
                        entrada   = Console.ReadLine().ToUpper();
                        PalabraOK = Juego.FiltrarPalabra(entrada);
                    } while (!PalabraOK);

                    letra     = entrada[0];
                    Juego.fin = Juego.ComprobarLetra(letra, palabra);// comprobamos letra
                } while (!Juego.fin && Juego.intentos != 7);


                if (Juego.fin)
                {
                    Console.WriteLine("enhorabuena has acertado la palabra oculta '{0}'", palabra);
                }
                else
                {
                    Dibujo.GameOver();
                    Console.WriteLine("Lo siento no acertaste la palabra. la palabra era {0}, te quedaste en {1}", palabra, Juego.hword);
                }
                Console.WriteLine("Pulse un boton para continuar...");
                Console.ReadKey();
                System.Console.Clear();
                Console.Write("Quieres jugar otra partida)\n>(S)i\n>(N)o\n->");
                entrada = Console.ReadLine().ToUpper();
                resp    = entrada[0];
            } while (resp != 'N');
            Console.WriteLine("Hasta otraaaaa!!");
            Console.WriteLine("Pulse un boton para continuar...");
            Console.ReadKey();
            IOFiles.CerrarArchivo();

            //IOFiles.file.Close();
        }
Exemplo n.º 7
0
 void ButtonReturnClick(object sender, EventArgs e)
 {
     YandexTranslator.Key = textBox1.Text;
     IOFiles.SaveConfigFile();
     Close();
 }