15-09-19, 04:55 AM
هذة المثود تقوم بالبحث عن الملف حسب الاسم اذا كان موجود :
وهذة المثود تقوم بايجاد النص و تقوم بفتح ملف الورد و تقوم بتحديد النص:
وهذا المشروع كامل:
PHP كود :
private string Filename()
{
try
{
string partialName = "Rabee Qabaha";
DirectoryInfo hdDirectoryInWhichToSearch = new DirectoryInfo(@"\\Mac\Home\Desktop\test");
FileInfo[] filesInDir = hdDirectoryInWhichToSearch.GetFiles("*" + partialName + "*.*");
string fullName = "";
foreach (FileInfo foundFile in filesInDir)
{
fullName = foundFile.FullName;
}
return fullName;
}
catch (Exception)
{
return "";
}
}
وهذة المثود تقوم بايجاد النص و تقوم بفتح ملف الورد و تقوم بتحديد النص:
PHP كود :
protected bool FindTextInWord(object texttofind, string filepath)
{
object matchCase = false;
object matchWholeWord = true;
object matchWildCards = false;
object matchSoundsLike = false;
object matchAllWordForms = false;
object forward = true;
object format = false;
object matchKashida = false;
object matchDiacritics = false;
object matchAlefHamza = false;
object matchControl = false;
object read_only = false;
object visible = true;
object replace = 2;
object wrap = 1;
Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document docOpen = app.Documents.Open(filepath);
bool val = false;
try
{
val = app.Selection.Find.Execute(ref texttofind, ref matchCase, ref matchWholeWord,
ref matchWildCards, ref matchSoundsLike, ref matchAllWordForms, ref forward, ref wrap,
ref format, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
finally
{
//app.Documents.Close();
}
return val;
}
وهذا المشروع كامل:
