-
@אוריי
https://markheath.net/post/how-to-get-media-file-duration-in-c
ואותו רעיון אבל בלי ספרייה חיצונית:
https://stackoverflow.com/a/1284520/8997905 -
@אוריי
https://markheath.net/post/how-to-get-media-file-duration-in-c
ואותו רעיון אבל בלי ספרייה חיצונית:
https://stackoverflow.com/a/1284520/8997905@yossiz , לגבי הקוד הראשון שהבאת
זה מחזיר לי שגיאה בclassSeverity Code Description Project File Line Suppression State Error CS1106 Extension method must be defined in a non-generic static class SearchByTime C:\Users\uri\source\repos\SearchByTime\SearchByTime\Form1.cs 16 Active
-
@yossiz , לגבי הקוד הראשון שהבאת
זה מחזיר לי שגיאה בclassSeverity Code Description Project File Line Suppression State Error CS1106 Extension method must be defined in a non-generic static class SearchByTime C:\Users\uri\source\repos\SearchByTime\SearchByTime\Form1.cs 16 Active
@אוריי אמר באורך הסרטה ב #C:
לגבי הקוד הראשון שהבאת
זה מחזיר לי שגיאה בclassאתה מתכוון לקוד השני? בראשון אין בכלל extension method.
הפתרון הוא להכניס את הפונקציה לתוך קלאס סטטי. כזה:static class Helpers { public static Dictionary<string, string> GetDetails(this FileInfo fi) { Dictionary<string, string> ret = new Dictionary<string, string>(); Shell shl = new Shell(); Folder folder = shl.NameSpace(fi.DirectoryName); FolderItem item = folder.ParseName(fi.Name); for (int i = 0; i < 150; i++) { string dtlDesc = folder.GetDetailsOf(null, i); string dtlVal = folder.GetDetailsOf(item, i); if (dtlVal == null || dtlVal == "") continue; ret.Add(dtlDesc, dtlVal); } return ret; } }
-
@רחמים אני הייתי פוסל קוד כזה ב-code review (כמובן, ההכרח לא יגונה, אבל אם יש דרך אחר זה לא הייתי עושה את זה)
-
@רחמים לא רק ביצועים, (אבל גם), אלא זה כמו לבנות בנין שלם כדי לבדוק מידות של אחת מהחלונות...
-
@yossiz מה חוץ מביצועים? כי המשל שהזכרת מדבר רק על ביצועים, [והוא גם מאוד מוגזם ביחס לנמשל].
-
@רחמים זו דרך עקומה. בלי סיבה, למה ללכת בה? כך אני סבור. זכותך לחלוק. (אם בדרך שלך היו ביצועים יותר טובים, ניחא. אבל אין.).
(יש אומנם נקודת זכות לדרך שלך שהיא יותר פשוטה למי שלא מתכנת מנוסה) -
@אוריי אמר באורך הסרטה ב #C:
לגבי הקוד הראשון שהבאת
זה מחזיר לי שגיאה בclassאתה מתכוון לקוד השני? בראשון אין בכלל extension method.
הפתרון הוא להכניס את הפונקציה לתוך קלאס סטטי. כזה:static class Helpers { public static Dictionary<string, string> GetDetails(this FileInfo fi) { Dictionary<string, string> ret = new Dictionary<string, string>(); Shell shl = new Shell(); Folder folder = shl.NameSpace(fi.DirectoryName); FolderItem item = folder.ParseName(fi.Name); for (int i = 0; i < 150; i++) { string dtlDesc = folder.GetDetailsOf(null, i); string dtlVal = folder.GetDetailsOf(item, i); if (dtlVal == null || dtlVal == "") continue; ret.Add(dtlDesc, dtlVal); } return ret; } }
-
@yossiz ,
כך הפעלתי את הפונקציה
var ee = Helpers.GetDetails(file);
וזה הערך שהפונקציה מחזירה (במקום לקבל זמן)
System.Collections.Generic.Dictionary`2[System.String,System.String]
@אוריי נכון, הפונצקיה מחזרת dictionary של כל המאפיינים של הקובץ. אתה צריך רק מאפיין מס' 27. צריך להתאים את הקוד קצת.
static class Helpers { public static TimeSpan GetMediaLength(this FileInfo fi) { Shell shl = new Shell(); Folder folder = shl.NameSpace(fi.DirectoryName); FolderItem item = folder.ParseName(fi.Name); string timeSpanStr = folder.GetDetailsOf(item, 27); return TimeSpan.Parse(timeSpanStr); } }
-
@אוריי נכון, הפונצקיה מחזרת dictionary של כל המאפיינים של הקובץ. אתה צריך רק מאפיין מס' 27. צריך להתאים את הקוד קצת.
static class Helpers { public static TimeSpan GetMediaLength(this FileInfo fi) { Shell shl = new Shell(); Folder folder = shl.NameSpace(fi.DirectoryName); FolderItem item = folder.ParseName(fi.Name); string timeSpanStr = folder.GetDetailsOf(item, 27); return TimeSpan.Parse(timeSpanStr); } }
-
@אוריי נכון, הפונצקיה מחזרת dictionary של כל המאפיינים של הקובץ. אתה צריך רק מאפיין מס' 27. צריך להתאים את הקוד קצת.
static class Helpers { public static TimeSpan GetMediaLength(this FileInfo fi) { Shell shl = new Shell(); Folder folder = shl.NameSpace(fi.DirectoryName); FolderItem item = folder.ParseName(fi.Name); string timeSpanStr = folder.GetDetailsOf(item, 27); return TimeSpan.Parse(timeSpanStr); } }
-
D dovid העביר נושא זה מ-תכנות ב-