ReadToEnd() public method

public ReadToEnd ( ) : string
return string
Example #1
1
        private void DlgTips_Load(object sender, EventArgs e)
        {   
            try
            {
                string strxml = "";
                using (StreamReader streamReader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Johnny.Kaixin.WinUI.Resources.Versions.config")))
                {
                    strxml = streamReader.ReadToEnd();
                }

                XmlDocument objXmlDoc = new XmlDocument();
                objXmlDoc.LoadXml(strxml);

                if (objXmlDoc == null)
                    return;

                DataView dv = GetData(objXmlDoc, "ZrAssistant/Versions");

                for (int ix = 0; ix < dv.Table.Rows.Count; ix++)
                {
                    _versionList.Add(dv.Table.Rows[ix][0].ToString(), dv.Table.Rows[ix][1].ToString());
                    cmbVersion.Items.Add(dv.Table.Rows[ix][0].ToString());
                }

                chkNeverDisplay.Checked = Properties.Settings.Default.NeverDisplay;
                cmbVersion.SelectedIndex = 0;
                SetTextValue();
                btnOk.Select();
            }
            catch (Exception ex)
            {
                Program.ShowMessageBox("DlgTips", ex);
            }
        }
Example #2
1
        public static void Extract(Category category)
        {
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data", "Extract");
            if(!Directory.Exists(path))
                Directory.CreateDirectory(path);

            pset.Clear();
            pdic.Clear();
            string downPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data", "Down", category.Name);
            string fileName = string.Format(@"{0}\{1}.txt", path, category.Name);

            StreamWriter sw = new StreamWriter(fileName, false, Encoding.UTF8);
            for (int i = category.DownPageCount; i >= 1; i--)
            {
                string htmlFileName = string.Format(@"{0}\{1}.html", downPath, i);
                if (!File.Exists(htmlFileName))
                    Logger.Instance.Write(string.Format("{0}-{1}.html-not exist", category.Name, i));
                StreamReader sr = new StreamReader(htmlFileName, Encoding.UTF8);
                string text = sr.ReadToEnd();
                sr.Close();

                var action = CreateAction(category.Type);
                if (action == null) continue;

                Extract(text, sw, category.Name,category.DbName, action);
            }
            sw.Close();

            Console.WriteLine("{0}:Extract Data Finished!", category.Name);
        }
Example #3
1
 public static List<DeepBlue.Models.Entity.DealClosingCostType> GetDealClosingCostTypesFromDeepBlue(CookieCollection cookies)
 {
     // Admin/DealClosingCostTypeList?pageIndex=1&pageSize=5000&sortName=Name&sortOrder=asc
     List<DeepBlue.Models.Entity.DealClosingCostType> dealClosingCostTypes = new List<DeepBlue.Models.Entity.DealClosingCostType>();
     // Send the request
     string url = HttpWebRequestUtil.GetUrl("Admin/DealClosingCostTypeList?pageIndex=1&pageSize=5000&sortName=Name&sortOrder=asc");
     HttpWebResponse response = HttpWebRequestUtil.SendRequest(url, null, false, cookies, false, HttpWebRequestUtil.JsonContentType);
     if (response.StatusCode == System.Net.HttpStatusCode.OK) {
         using (Stream receiveStream = response.GetResponseStream()) {
             // Pipes the stream to a higher level stream reader with the required encoding format.
             using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8)) {
                 string resp = readStream.ReadToEnd();
                 if (!string.IsNullOrEmpty(resp)) {
                     JavaScriptSerializer js = new JavaScriptSerializer();
                     FlexigridData flexiGrid = (FlexigridData)js.Deserialize(resp, typeof(FlexigridData));
                     foreach (Helpers.FlexigridRow row in flexiGrid.rows) {
                         DeepBlue.Models.Entity.DealClosingCostType dealClosingType = new DeepBlue.Models.Entity.DealClosingCostType();
                         dealClosingType.DealClosingCostTypeID = Convert.ToInt32(row.cell[0]);
                         dealClosingType.Name = Convert.ToString(row.cell[1]);
                         dealClosingCostTypes.Add(dealClosingType);
                     }
                 }
                 else {
                 }
                 response.Close();
                 readStream.Close();
             }
         }
     }
     return dealClosingCostTypes;
 }
 private string ReadFromFSLocation(string path)
 {
     using (StreamReader sr = new StreamReader(path))
     {
         return sr.ReadToEnd().Trim();
     }
 }
Example #5
1
 private void sendMessage()
 {
     MailAddress adresa = new MailAddress("[email protected]");
     MailMessage zpráva;
     if (logFile)
     {
         string log;
         using (StreamReader reader = new StreamReader(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Info", "Log", "logStatusBaru.log")))
         {
             log = reader.ReadToEnd();
         }
         if (log.Length > 50000)
             log.Remove(50000);
         zpráva = new MailMessage("[email protected]", "[email protected]", předmětTextBox.Text, textZprávyTextBox.Text + log);
     }
     else
     {
         zpráva = new MailMessage("[email protected]", "[email protected]", předmětTextBox.Text, textZprávyTextBox.Text);
     }
     SmtpClient klient = new SmtpClient();
     klient.Host = "smtp.gmail.com";
     klient.Port = 465;
     klient.EnableSsl = true;
     //klient.Send(zpráva);
 }
        /// <summary>
        /// loads a xml from the web server
        /// </summary>
        /// <param name="_url">URL of the XML file</param>
        /// <returns>A XmlDocument object of the XML file</returns>
        public static XmlDocument LoadXml(string _url)
        {
            var xmlDoc = new XmlDocument();
            
            try
            {
                while (Helper.pingForum("forum.mods.de", 10000) == false)
                {
                    Console.WriteLine("Can't reach forum.mods.de right now, try again in 15 seconds...");
                    System.Threading.Thread.Sleep(15000);
                }

                xmlDoc.Load(_url);
            }
            catch (XmlException)
            {
                while (Helper.pingForum("forum.mods.de", 100000) == false)
                {
                    Console.WriteLine("Can't reach forum.mods.de right now, try again in 15 seconds...");
                    System.Threading.Thread.Sleep(15000);
                }

                WebClient client = new WebClient(); ;
                Stream stream = client.OpenRead(_url);
                StreamReader reader = new StreamReader(stream);
                string content = reader.ReadToEnd();

                content = RemoveTroublesomeCharacters(content);
                xmlDoc.LoadXml(content);
            }

            return xmlDoc;
        }
Example #7
1
        public GeoIP()
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://freegeoip.net/xml/");
                request.Proxy = null;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream dataStream = response.GetResponseStream();
                StreamReader reader = new StreamReader(dataStream);
                string responseString = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
                response.Close();

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(responseString);

                WANIP = doc.SelectSingleNode("Response//Ip").InnerXml.ToString();
                Country = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryName").InnerXml.ToString())) ? doc.SelectSingleNode("Response//CountryName").InnerXml.ToString() : "Unknown";
                CountryCode = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryCode").InnerXml.ToString())) ? doc.SelectSingleNode("Response//CountryCode").InnerXml.ToString() : "-";
                Region = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//RegionName").InnerXml.ToString())) ? doc.SelectSingleNode("Response//RegionName").InnerXml.ToString() : "Unknown";
                City = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//City").InnerXml.ToString())) ? doc.SelectSingleNode("Response//City").InnerXml.ToString() : "Unknown";
            }
            catch
            {
                WANIP = "-";
                Country = "Unknown";
                CountryCode = "-";
                Region = "Unknown";
                City = "Unknown";
            }
        }
Example #8
1
        public Shader(GraphicsDevice dev, string name)
        {
            this.dev = dev;
            string code;
            using (var file = new StreamReader(FileSystem.Open("cg{0}{1}.fx".F(Path.DirectorySeparatorChar, name))))
                code = file.ReadToEnd();
            effect = Tao.Cg.Cg.cgCreateEffect(dev.Context, code, null);

            if (effect == IntPtr.Zero)
            {
                var err = Tao.Cg.Cg.cgGetErrorString(Tao.Cg.Cg.cgGetError());
                var results = Tao.Cg.Cg.cgGetLastListing(dev.Context);
                throw new InvalidOperationException(
                    "Cg compile failed ({0}):\n{1}".F(err, results));
            }

            technique = Tao.Cg.Cg.cgGetFirstTechnique(effect);
            if (technique == IntPtr.Zero)
                throw new InvalidOperationException("No techniques");
            while (Tao.Cg.Cg.cgValidateTechnique(technique) == 0)
            {
                technique = Tao.Cg.Cg.cgGetNextTechnique(technique);
                if (technique == IntPtr.Zero)
                    throw new InvalidOperationException("No valid techniques");
            }
        }
Example #9
1
        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="fileName"></param>
        public void Delete(string fileName)
        {
            try
            {
                string uri = ftpURI + fileName;
                FtpWebRequest reqFTP;
                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));

                reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
                reqFTP.KeepAlive = false;
                reqFTP.Method = WebRequestMethods.Ftp.DeleteFile;

                string result = String.Empty;
                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
                long size = response.ContentLength;
                Stream datastream = response.GetResponseStream();
                StreamReader sr = new StreamReader(datastream);
                result = sr.ReadToEnd();
                sr.Close();
                datastream.Close();
                response.Close();
            }
            catch (Exception ex)
            {
                Insert_Standard_ErrorLog.Insert("FtpWeb", "Delete Error --> " + ex.Message + "  文件名:" + fileName);
            }
        }
        public static void Main()
        {
            var url = new Uri(ApiUrl + "?auth-id=" + AuthenticationID + "&auth-token=" + AuthenticationToken);
            var request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";

            using (var stream = request.GetRequestStream())
            using (var writer = new StreamWriter(stream))
                writer.Write(RequestPayload);

            using (var response = request.GetResponse())
            using (var stream = response.GetResponseStream())
            using (var reader = new StreamReader(stream))
            {
                var rawResponse = reader.ReadToEnd();
                Console.WriteLine(rawResponse);

                // Suppose you wanted to use Json.Net to pretty-print the response (delete the next two lines if not):
                // Json.Net: http://http://json.codeplex.com/
                dynamic parsedJson = JsonConvert.DeserializeObject(rawResponse);
                Console.WriteLine(JsonConvert.SerializeObject(parsedJson, Formatting.Indented));

                // Or suppose you wanted to deserialize the json response to a defined structure (defined below):
                var candidates = JsonConvert.DeserializeObject<CandidateAddress[]>(rawResponse);
                foreach (var address in candidates)
                    Console.WriteLine(address.DeliveryLine1);
            }

            Console.ReadLine();
        }
Example #11
0
        private static void AppendToVCProjectItemsVsDir(string projectItemsFile)
        {
            var nameSpace = Assembly.GetExecutingAssembly().GetName().Name;
            var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format("{0}.VCProjectItems_vsdir_append.txt", nameSpace));
            if (resourceStream == null)
                throw new Exception("Missing resource: VCProjectItems_vsdir_append.txt");

            bool needsNewLine = false;
            var readContents = File.ReadAllText(projectItemsFile);
            if (!readContents.EndsWith(Environment.NewLine))
            {
                needsNewLine = true;
            }

            using (var reader = new StreamReader(resourceStream))
            {
                string contents;
                if (needsNewLine)
                {
                    contents = Environment.NewLine + reader.ReadToEnd();
                }
                else
                {
                    contents = reader.ReadToEnd();
                }

                File.AppendAllText(projectItemsFile, contents);
                Console.WriteLine(string.Format("installed: {0}", projectItemsFile));
            }
        }
        private static void GetCss(IEnumerable<FileInfo> files, out string css, out string cssmini)
        {
            Global.Log.Debug("Rebuilding CSS.");
            var output = new StringBuilder("/* Generated on {0} */\n".F(DateTime.Now));

            foreach (var file in files) {
                using (var stream = file.Open(FileMode.Open)) {
                    using (var reader = new StreamReader(stream)) {
                        // Append a little comment with the filename separating each file for clarity
                        output.Append("\n/********\n * {0}  \n */\n\n".F(file.Name));
                        switch (file.Extension) {
                            case ".css":
                                output.Append(reader.ReadToEnd());
                                break;
                            case ".less":
                                output.Append(Less.Parse(reader.ReadToEnd()));
                                break;
                        }
                    }
                }
            }

            css = output.ToString();
            cssmini = Compress(output.ToString());
        }
Example #13
0
        public HTTPConnection(HttpListenerContext c)
        {
            context = c;

            HttpListenerRequest request = context.Request;

            arguments.Clear();

            // get our base keys
            if (request.QueryString.HasKeys())
            {
                for (int i = 0; i < request.QueryString.Count; i++)
                {
                    string name = request.QueryString.GetKey(i);
                    string value = string.Empty;

                    if (request.QueryString.GetValues(i).GetLength(0) > 0)
                        value = request.QueryString.GetValues(i)[0];

                    arguments.Add(name, value);
                }
            }

            if (request.HttpMethod == "POST")
            {
                StreamReader reader = new System.IO.StreamReader(request.InputStream, request.ContentEncoding);
                string body = reader.ReadToEnd();

                while (body.Length < request.ContentLength64) // go untill we have the entire thing
                {
                    body += reader.ReadToEnd();
                    Thread.Sleep(100);
                    Console.WriteLine("readloop body read " + body.Length.ToString() + " : expected size " + request.ContentLength64.ToString() + "request flag " + request.HasEntityBody.ToString());
                }

                reader.Close();
                request.InputStream.Close();

                string[] pairs = body.Split('&');

                foreach (string s in pairs)
                {
                    string[] item = s.Split('=');

                    string name = item[0];
                    string value = string.Empty;

                    if (item.Length > 1 && item[1].Length > 0)
                        value = HttpUtility.UrlDecode(item[1]);

                    if (!arguments.ContainsKey(name))
                        arguments.Add(name, value);
                    else
                        arguments[name] = value;

                    Console.WriteLine("argument " + name + " : " + value);

                }
            }
        }
Example #14
0
 public string GET(string url, Encoding _encoding, Boolean needHeaders = false)
 {
     try
     {
         HttpWebRequest hwrq = CreateRequest(url);
         if (Environment.UserDomainName == "GRADIENT")
             hwrq.Credentials = CredentialCache.DefaultNetworkCredentials;
         else
         {
             Configuration currentConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
             Decryptor decryptor = new Decryptor(currentConfig.AppSettings.Settings["Password"].Value);
             hwrq.Credentials = new NetworkCredential(currentConfig.AppSettings.Settings["User"].Value, decryptor.DescryptStr, currentConfig.AppSettings.Settings["Domian"].Value);
         }
         hwrq.CookieContainer = Cookies;
         using (HttpWebResponse hwrs = (HttpWebResponse)hwrq.GetResponse())
         {
             Cookies.Add(hwrs.Cookies);
             using (StreamReader sr = new StreamReader(hwrs.GetResponseStream(), _encoding))
             {
                 if (needHeaders)
                     return hwrs.Headers.ToString() + sr.ReadToEnd().Trim();
                 else
                     return sr.ReadToEnd().Trim();
             }
         }
     }
     catch (Exception e)
     {
         return null;
     }
 }
Example #15
0
        public static HtmlDocument Download(AbsoluteUri location)
        {
            if (null == location)
            {
                throw new ArgumentNullException("location");
            }

            HtmlDocument html = null;

            var request = WebRequest.Create((Uri)location);
            using (var response = request.GetResponse())
            {
                using (var stream = response.GetResponseStream())
                {
                    if (null != stream)
                    {
                        using (var reader = new StreamReader(stream))
                        {
#if NET20
                            var file = new FileInfo(StringExtensionMethods.FormatWith("{0}.html", AlphaDecimal.Random()));
                            FileInfoExtensionMethods.Create(file, reader.ReadToEnd());
#else
                            var file = new FileInfo("{0}.html".FormatWith(AlphaDecimal.Random()));
                            file.Create(reader.ReadToEnd());
#endif

                            html = new HtmlDocument();
                            html.Load(file.FullName);
                        }
                    }
                }
            }

            return html;
        }
Example #16
0
        /// <summary>
        /// Process the request
        /// </summary>
        public void ProcessRequest(HttpContext context)
        {
            DateTime mod = new FileInfo(Assembly.GetExecutingAssembly().Location).LastWriteTime ;
            if (File.Exists(context.Server.MapPath("~/Areas/Manager/Content/Css/Style.css"))) {
                FileInfo file = new FileInfo(context.Server.MapPath("~/Areas/Manager/Content/Css/Style.css")) ;
                mod = file.LastWriteTime > mod ? file.LastWriteTime : mod ;
            }

            if (!WebPiranha.HandleClientCache(context, resource, mod)) {
                StreamReader io = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resource)) ;
                context.Response.ContentType = "text/css" ;
            #if DEBUG
                context.Response.Write(io.ReadToEnd()) ;
            #else
                context.Response.Write(CssCompressor.Compress(io.ReadToEnd()).Replace("\n","")) ;
            #endif
                io.Close() ;

                // Now check for application specific styles
                if (File.Exists(context.Server.MapPath("~/Areas/Manager/Content/Css/Style.css"))) {
                    io = new StreamReader(context.Server.MapPath("~/Areas/Manager/Content/Css/Style.css")) ;
            #if DEBUG
                    context.Response.Write(io.ReadToEnd()) ;
            #else
                    context.Response.Write(CssCompressor.Compress(io.ReadToEnd()).Replace("\n","")) ;
            #endif
                    io.Close() ;
                }
            }
        }
Example #17
0
 private static void RequestResponse(string sender, string requestUrl, ref string sessionId)
 {
     HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUrl);
     using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
     {
         using (var reader = new StreamReader(response.GetResponseStream()))
         {
             if (!sender.Equals("initialize"))
             {
                 File.WriteAllText(string.Format("{0}.json", sender), reader.ReadToEnd());
             }
             else
             {
                 JavaScriptSerializer js = new JavaScriptSerializer();
                 var obj = js.Deserialize<dynamic>(reader.ReadToEnd());
                 foreach (var o in obj)
                 {
                     if (o.Key == "session_id")
                     {
                         sessionId = o.Value;
                     }
                 }
             }
         }
     }
 }
Example #18
0
 /// <summary>
 /// 银行对账表(返回列表JSON)
 /// </summary>
 /// <param name="keywords">关键字</param>
 /// <returns></returns>
 public List<BankAnalyze> GetBankAnalyzeList(string filepath, string keywords)
 {
     FileStream fs = new System.IO.FileStream(filepath, FileMode.Open, System.IO.FileAccess.Read, FileShare.ReadWrite);
     StreamReader sr = new StreamReader(fs, Encoding.GetEncoding("gb2312"));//取得这txt文件的编码
     int PageSize = 40;
     List<BankAnalyze> ListData = new List<BankAnalyze>();
     if (!string.IsNullOrEmpty(keywords))
     {
         //Linq模糊查询
         ListData = (from itementity in JsonHelper.JonsToList<BankAnalyze>(sr.ReadToEnd().ToString())
                     where itementity.Month.Contains(keywords)
                     || itementity.Remark.Contains(keywords)
                     || itementity.CreateDate.Contains(keywords.ToUpper())
                     select itementity).Take(PageSize).ToList<BankAnalyze>();
     }
     else
     {
         ListData = JsonHelper.JonsToList<BankAnalyze>(sr.ReadToEnd().ToString()).Take(PageSize).ToList<BankAnalyze>();
     }
     var JsonData = new
     {
         rows = ListData,
     };
     return ListData;
 }
Example #19
0
        public void Process(ToolContext context)
        {
            foreach (WorkfileContext workContext in context.Workfiles)
            {
                string extension = Path.GetExtension(workContext.Workfile.Name).ToLower();
                if (extension == ".css" || extension == ".js")
                {
                    string compressed = null;
                    using (var stream = new FileStream(workContext.Workfile.FullName, FileMode.Open, FileAccess.Read, FileShare.None))
                    {
                        using (var reader = new StreamReader(stream))
                        {
                            switch (extension)
                            {
                                case ".css":
                                    compressed = CssCompressor.Compress(reader.ReadToEnd());
                                    break;
                                case ".js":
                                    compressed = JavaScriptCompressor.Compress(reader.ReadToEnd());
                                    break;
                            }
                        }
                    }

                    using (var writer = new StreamWriter(workContext.Workfile.FullName, false))
                    {
                        writer.Write(compressed);
                    }
                }
            }
        }
Example #20
0
        public static FileInfo Download(AbsoluteUri location)
        {
            if (null == location)
            {
                throw new ArgumentNullException("location");
            }

            FileInfo file = null;

            var request = WebRequest.Create((Uri)location);
            using (var response = request.GetResponse())
            {
                using (var stream = response.GetResponseStream())
                {
                    if (null != stream)
                    {
                        using (var reader = new StreamReader(stream))
                        {
#if NET20
                            file = new FileInfo(StringExtensionMethods.FormatWith("{0}.json", AlphaDecimal.Random()));
                            FileInfoExtensionMethods.Create(file, reader.ReadToEnd());
#else
                            file = new FileInfo("{0}.json".FormatWith(AlphaDecimal.Random()));
                            file.Create(reader.ReadToEnd());
#endif
                        }
                    }
                }
            }

            return file;
        }
Example #21
0
 internal static int CalcLineCount(string filename)
 {
     int count;
     using (var sr = new StreamReader(filename, Encoding.Default, true))
     {
         count = sr.ReadToEnd().Length - sr.ReadToEnd().Replace("\r\n", "\n").Length;
         sr.Close();
     }
     return count;
 }
Example #22
0
 public void Seek_In_Read_Stream()
 {
     using (var stream = ExistingFile.CreateReadStream())
     using (var reader = new StreamReader(stream))
     {
         string wholeContents = reader.ReadToEnd();
         const int readOffset = 4;
         stream.Seek(readOffset, SeekOrigin.Begin);
         string endPart = reader.ReadToEnd();
         Assert.That(wholeContents.Substring(readOffset), Is.EqualTo(endPart));
     }
 }
        public string CreateStudentObject(Student student)
        {
            //var obj = new JavaScriptSerializer().Serialize(student);
            DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(Student));
            MemoryStream ms = new MemoryStream();
            js.WriteObject(ms, student);
            Console.WriteLine("\r\nUdemy.com - Serializing and Deserializing JSON in C#\r\n");
            ms.Position = 0;
            StreamReader sr = new StreamReader(ms);
            Console.WriteLine(sr.ReadToEnd());

            return sr.ReadToEnd();
        }
Example #24
0
 static void PrintXML(Stream s, bool saveToFile, string fileName)
 {
     using (StreamReader r = new StreamReader(s))
     {
         if (saveToFile)
         {
             File.WriteAllText(fileName, r.ReadToEnd());
             Console.WriteLine("Check file " + fileName + "\n");
         }
         else
             Console.WriteLine(r.ReadToEnd());
     }
 }
 public string GetC(string path, bool Long = false)
 {
     using (StreamReader G = new StreamReader(path))
     {
         if (Long == false)
         {
             char[] readG = G.ReadToEnd().ToCharArray();
             return readG[0].ToString();
         }
         else
             return G.ReadToEnd();
     }
 }
Example #26
0
 public void LoadShaderFromFile(String filename, ShaderType type)
 {
     using (StreamReader sr = new StreamReader(filename))
     {
         if (type == ShaderType.VertexShader)
         {
             loadShader(sr.ReadToEnd(), type, out VShaderID);
         }
         else if (type == ShaderType.FragmentShader)
         {
             loadShader(sr.ReadToEnd(), type, out FShaderID);
         }
     }
 }
Example #27
0
        void WebView_Navigating(object sender, System.Windows.Forms.WebBrowserNavigatingEventArgs e)
        {
            String viewRoot = "views\\";
            String disponent = e.Url.ToString().Split(':')[0];
            String app = e.Url.ToString().Split(':')[1];
            String argument = e.Url.ToString().Replace(disponent+":"+app+":","");
            using(StreamReader SR = new StreamReader(viewRoot+argument+".xml"))
            {

                RawCode = SR.ReadToEnd();
                Source = mMakoEngine.Preprocess(SR.ReadToEnd(), argument, false, disponent + ":" + app + ":" + argument, false);

            }
        }
Example #28
0
        /// <summary>
        /// Process the request
        /// </summary>
        public void ProcessRequest(HttpContext context)
        {
            DateTime mod = new FileInfo(Assembly.GetExecutingAssembly().Location).LastWriteTime ;

            if (!ClientCache.HandleClientCache(context, resource, mod)) {
                StreamReader io = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resource)) ;
                context.Response.ContentType = "text/javascript" ;
            #if DEBUG
                context.Response.Write(io.ReadToEnd()) ;
            #else
                context.Response.Write(JavaScriptCompressor.Compress(io.ReadToEnd())) ;
            #endif
                io.Close() ;
            }
        }
        private void ChangeCopyright()
        {
            UpdateLabel("searching for rotmg version display string");
            Dictionary<string, string> files = new Dictionary<string, string>();
            string filetext = String.Empty;

            foreach (string path in this.files)
            {
                using (StreamReader rdr = new StreamReader(File.Open(path, FileMode.Open)))
                {
                    filetext = rdr.ReadToEnd();
                    if (filetext.Contains(ROTMG_VERSION_TEXT))
                    {
                        UpdateLabel("request found!");
                        files.Add(path, filetext);
                    }
                }
            }

            foreach (var file in files)
            {
                UpdateLabel("replacing version text");
                filetext = file.Value.Replace(ROTMG_VERSION_TEXT, "<font color='#00CCFF'>Fabiano Swagger of Doom</font> #{VERSION}.{MINORVERSION}");
                filetext = filetext.Replace("{MINOR}", "{MINORVERSION}");
                using (StreamWriter wtr = new StreamWriter(file.Key, false))
                    wtr.Write(filetext);
            }
            UpdateLabel("Version Display: Done!");
        }
		public string GetFileContent(string filePath)
		{
			if (string.IsNullOrWhiteSpace(filePath))
			{
				throw new ArgumentException(
					string.Format(CommonStrings.ErrorMessage_FilePathNotSpecified, filePath),
					"filePath"
				);
			}

			string content;
			string fullFilePath = _textContentDirectoryPath.TrimEnd('/') + "/" + filePath;
			string physicalFilePath = GetPhysicalFilePath(fullFilePath);

			try
			{
				using (FileStream fileStream = File.OpenRead(physicalFilePath))
				using (var reader = new StreamReader(fileStream))
				{
					content = reader.ReadToEnd();
				}
			}
			catch (FileNotFoundException)
			{
				throw new FileNotFoundException(
					string.Format(CommonStrings.ErrorMessage_FileNotFound, filePath));
			}
			catch (DirectoryNotFoundException)
			{
				throw new FileNotFoundException(
					string.Format(CommonStrings.ErrorMessage_FileNotFound, filePath));
			}

			return content;
		}