我正在製作一個應用程序,將該遊戲的分辨率更改爲請求的分辨率。C#替換通配符
StreamReader reader = new StreamReader(@"C:\Documents and Settings\ARTech\Bureaublad\PersistentSymbols.ini");//Reads the file.
string content = reader.ReadToEnd();//Puts the content of the file, into a variable.
reader.Close();
string replace = "persistent extern INDEX m_pixScreenWidth=(INDEX)" + txtWidth.Text + ";";
content = content.Replace("persistent extern INDEX m_pixScreenWidth=(INDEX)1920;", replace);//Replaces the ScreenWidth of the game to the requested number.
replace = "persistent extern INDEX m_pixScreenHeight=(INDEX)" + txtHeight.Text + ";";
content = content.Replace("persistent extern INDEX m_pixScreenHeight=(INDEX)1200;", replace);//Replaces the ScreenHeight of the game to the requested number.
StreamWriter writer = new StreamWriter(@"C:\Documents and Settings\ARTech\Bureaublad\PersistentSymbols.ini");
writer.Write(content);//Saves the changes.
writer.Close();
的問題是,這項決議並不總是1920×1200,所以我需要某種形式的通配符,它接受persistent extern INDEX m_pixScreenWidth=(INDEX)
和;
之間的一切。
不久,你需要得到像m_pixScreenHeight = [0-9] *的東西作爲一個正則表達式 – ykatchou 2010-10-20 14:58:04