Forum Collection Satisfaction: C #

zhaozj2021-02-16  63

*********************************************************** ****************** Title: How to prevent a Windows program from being activated multiple sources: http://community.9cbs.net/expert/topic/2945/2945464. XML? Temp = .7424738 ******************************************************* ************************ You can use the mutex Mutex type to complete this feature. See the following code: [stathread] public static void main (string [] args) {// declares the mutex. Mutex Mutex = New Mutex (False, "ThisSholdonlyRunon"); // Judging whether the mutex is used. Bool running =! Mutex.waitone (0, false); if (! Running) Application.run (New Formlogin ()); Else MessageBox.show ("Application has started!");}

*********************************************************** ******************* Title: Operation text Source: http://community.9cbs.net/expert/topic/3122/3122376.xml? Temp = 1.827419E- 03 ********************************************************** ******************* // read text file filename.text = filename; filestream fs = new filestream (server.mappath (") " // " filename, filemode.open, fileaccess.read); // Use the default encoding to read the contents of the Open file StreamReader SR = New StreamReader (FS, Encoding.default); stringbuilder output = new stringbuilder (); string rl; While ((rl = sr.readline ())! = null) {Output.Append (rl); output.append ("/ n");} sr.close (); fs.close (); filet.Text = Output;

//save document

FILESTREAM FW = New FileStream (FilePath FileName, FileMode.create, FileAccess.write); // Establishing streamWrite to prepare for writing

StreamWriter rw = new streamwriter (fw, encoding.default); rw.write (filetxt.text.tostring ()); rw.close (); fw.close ();

Use the above code to read the data, you can save it after you change. *********************************************************** ******************* Title: How to get a table's structure Source: http://community.9cbs.net/expert/topic / 3163/3163386.xml?temp=9.685916e-02**************************************************** ******************************** ///

/// return all table /// /// Public Static DataTable getTables () {dataable dt = new dataable ();

Try {con.open (); dt = con.getoledbschematable (OLEDBSChemaGuid.tables, new object [] {null, null, null, "table"});} catch (exception ex) {throw ex;} finally {con. CLOSE ();

Return dt;}

///

/// Returns the structure of the specified table /// /// /// public static datatable gettteable String Vartables) {dataable dt = new datatable ();

DataSet DS = New Dataset ();

OleDbDataAdapter Odb = new OleDbDataAdapter ( "select * from" varTableName, Con); try {Con.Open (); Odb.FillSchema (ds, SchemaType.Source, varTableName);} catch (Exception ex) {throw ex;} finally {Con. close ();} return ds.tables [varablename];

Related links: http://dotnet.aspx.cc/showdetail.aspx? Id = zp4kxo6x-i697-4i4r-ykyb-6kfvpbc5jjpu

转载请注明原文地址:https://www.9cbs.com/read-17232.html

New Post(0)