פורסם 2008 במאי 717 שנים שלום אנשים,אני צריך מעט עזרה עם קוד ב-C# לעריכת טקסט.הייתי רוצה קוד שיקרא קובץ טקסט שאני יצרתי (להלן -C:\xxxxxx.txt) ולאחר מכן בכל שורה ישנה מספר מסויים לאחר. למשל, שישנה כל ספרה 9 לספרה 8.אשמח מאוד אם מישהו יוכל לעזור לי בזה. זה בהחלט יקצר לי הרבה תהליכים. אפשר גם שהוא ישמור זאת באותו הקובץ, או שישמור זאת בקובץ חדש (את זה אני כבר יודע לעשות), אבל העיקר שיאכסן את הטקס המתוקן במשתנה כלשהו.
פורסם 2008 במאי 717 שנים מקווה שזה יעזור לך.using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Xml;using System.Linq;using System.Text;using System.Windows.Forms;using System.Threading;using System.IO;namespace testing{ public partial class Form1 : Form { public Form1() { InitializeComponent(); string fileName = @"c:\xxxxxx.txt"; string fileText = File.ReadAllText(fileName); fileText = fileText.Replace('8', '9'); UTF8Encoding encoder = new UTF8Encoding(); byte[] writeBytes = encoder.GetBytes(fileText); File.Delete(fileName); FileStream fs = new FileStream(fileName,FileMode.Create,FileAccess.ReadWrite); fs.Write(writeBytes,0,writeBytes.Length); fs.Flush(); fs.Close(); } }}
פורסם 2008 במאי 817 שנים מחבר אוקיי תודה בן אדם! מה שהכי עזר לי זה השימוש בפקודה סגנון: fileText = fileText.Replace('8', '9'); תודה איש
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.