Esempio n. 1
0
        public JsonInformationClass JsonSerilaize(string[] subLower, string[] SubUpper, string SearchTerm, int SearchLine, string path, bool IsSucces)
        {
            JsonInformationClass jsonObj = new JsonInformationClass();

            jsonObj.SubLowerr  = subLower;
            jsonObj.SubUpper   = SubUpper;
            jsonObj.SearchLine = SearchLine;
            jsonObj.SearchTerm = SearchTerm;
            jsonObj.Path       = path;
            jsonObj.IsSucces   = IsSucces;
            return(jsonObj);
        }
Esempio n. 2
0
        private void FileRead(object Json)
        {
            List <JsonInformationClass> shapes = new List <JsonInformationClass>();

            SearchAccessibleFiles(textBox4.Text, textBox3.Text);
            var files = Directory.GetFiles(textBox4.Text, "*.*", SearchOption.AllDirectories)
                        .Where(s => s.EndsWith(".txt") || s.EndsWith(".css") || s.EndsWith(".json") || s.EndsWith(".php") || s.EndsWith(".html"));

            foreach (var file in files)
            {
                SearchAccessibleFiles(textBox4.Text, textBox3.Text);
                var lines = System.IO.File.ReadAllLines(file);
                int deger = 0;

                for (int i = 0; i < lines.Length; i++)
                {
                    if (lines[i].Contains(textBox3.Text))
                    {
                        if (i <= 16)
                        {
                            JsonSerializer serializer = new JsonSerializer();
                            MessageBox.Show("istenilen degerler bulundu");
                            string[] subLower = null;

                            string[] subUpper = SubArray(lines, 0, i + 1);

                            //StreamWriter jsonStream = System.IO.File.CreateText(path);
                            //JsonSerializer jsonSerializer = new JsonSerializer();
                            //serializer.Serialize(jsonStream, sub);
                            //jsonStream.Close();
                            //        System.IO.File.AppendAllText(path, file + "/n Istenilen Deger" + i + textBox3.Text);
                            bool IsSucces = true;
                            Json = new JsonInformationClass();
                            string root      = Path.GetFileName(file);
                            string root2     = Path.GetPathRoot(file);
                            string pathFiles = root2 + root;
                            JsonInformationClass JsonData = JsonSerilaize(subLower, subUpper, textBox3.Text, i, pathFiles, IsSucces);

                            shapes.Add(JsonData);
                        }
                        else
                        {
                            deger = i;

                            string[] subLower = SubArray(lines, i - 15, 15);
                            int      a        = lines.Length - i;
                            if (a < 15)
                            {
                                bool                 IsSucces  = true;
                                string[]             subUpper2 = SubArray(lines, i, lines.Length - i);
                                string               root      = Path.GetFileName(file);
                                string               root2     = Path.GetPathRoot(file);
                                string               pathFiles = root2 + root;
                                JsonInformationClass JsonData2 = JsonSerilaize(subLower, subUpper2, textBox3.Text, i, pathFiles, IsSucces);

                                shapes.Add(JsonData2);
                            }
                            else
                            {
                                string[]             subUpper  = SubArray(lines, i, 15);
                                string[]             subLower2 = SubArray(lines, i - 15, 15);
                                bool                 IsSucces  = true;
                                string               root      = Path.GetFileName(file);
                                string               root2     = Path.GetPathRoot(file);
                                string               pathFiles = root2 + root;
                                JsonInformationClass JsonData  = JsonSerilaize(subLower2, subUpper, textBox3.Text, i, root, IsSucces);

                                shapes.Add(JsonData);
                            }
                            //    Console.WriteLine(sub);
                            //    string json = JsonConvert.SerializeObject(sub);
                            //     JsonSerializer serializer = new JsonSerializer();
                            //    StreamWriter jsonStream = System.IO.File.CreateText(@"C:/Users/admin/Desktop/test.json");
                            //    System.IO.File.AppendAllText(@"C:/Users/admin/Desktop/test.json", file + i + textBox3.Text);
                            //   object a =   JsonSerilaize(i-16, i+16, textBox3.Text, i, path, true);
                            //    string JsonData = JsonConvert.SerializeObject(a);
                            //   System.IO.File.WriteAllText(path, JsonData);
                        }
                    }
                }
            }
            string path       = @"C:\Users\admin\Desktop/test.json";
            string shapesData = JsonConvert.SerializeObject(shapes);

            System.IO.File.WriteAllText(path, shapesData);
        }
Esempio n. 3
0
        private void Button1_Click(object sender, EventArgs e)
        {
            JsonInformationClass json = new JsonInformationClass();

            FileRead(json);
        }