<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[עזרה | הוספת תכונות לתיקיה ב c#]]></title><description><![CDATA[<p dir="auto">שלום וברכה<br />
מישהו יודע איך להוסיף תכונות לתיקיה בלי שזה ימחק את התכונות הקיימות?<br />
זה מה שכתבתי</p>
<pre><code>DirectoryInfo di = Directory.CreateDirectory(path);
if (checkedListBox1.CheckedItems.Count != 0)
{
    di.Attributes = FileAttributes.Directory;
    if (checkedListBox1.SelectedIndex == 0)
        di.Attributes = FileAttributes.ReadOnly;
    if (checkedListBox1.SelectedIndex == 1)
        di.Attributes = FileAttributes.Hidden;
    if (checkedListBox1.SelectedIndex == 2)
        di.Attributes = FileAttributes.System;
}
</code></pre>
<p dir="auto">תודה רבה</p>
]]></description><link>https://tchumim.com/topic/11005/עזרה-הוספת-תכונות-לתיקיה-ב-c</link><generator>RSS for Node</generator><lastBuildDate>Mon, 08 Jun 2026 01:43:24 GMT</lastBuildDate><atom:link href="https://tchumim.com/topic/11005.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 06 Apr 2021 05:05:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to עזרה | הוספת תכונות לתיקיה ב c# on Tue, 06 Apr 2021 13:46:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/clickone">@<bdi>clickone</bdi></a><br />
א. אני לא כתבתי את הקוד, הוספתי מילה רק כדי שהוא ייחשב ל<strong>תקין</strong><br />
ב. בהחלט הייתי בוחר בif.<br />
ראשית, בגלל שזה רק שלושה אפשרויות.<br />
הקוד קומפליט לא כותב מתי זה מתחיל להיות כבד להשתמש בswitch<br />
אבל ברור לכולנו שלשני שורות זה מפגר, אז תרחיב את זה לארבע...<br />
שנית, אני לא אוהב את הswitch של c# בגלל המילה break<br />
מתי אני כן משתמש בו? כשיש מצב של כמה תנאים נכונים או כשיש ביצוע זהה לכמה תנאים (במקום הרבה || אז עושים switch ללא break). היום שכללו מאוד את הswitch והוא הדרך הכי אלגנטית בבדיקת טיפוסים ועוד, אבל לא התרגלתי אליו עדיין.</p>
]]></description><link>https://tchumim.com/post/121215</link><guid isPermaLink="true">https://tchumim.com/post/121215</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Tue, 06 Apr 2021 13:46:39 GMT</pubDate></item><item><title><![CDATA[Reply to עזרה | הוספת תכונות לתיקיה ב c# on Tue, 06 Apr 2021 11:13:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid">@<bdi>dovid</bdi></a> שאלה מהצד שקשורה לנושא:</p>
<p dir="auto">למה אתה מעדיף  else if ולא switch?<br />
לא יותר אלגנטי וברור?<br />
(נראה לי שב code complete ההמלצה היא ללכת לכיוון של switch במידה והשפה והמקרה מאפשרים את זה, כדי שלא יהיה קוד ספגטי)</p>
]]></description><link>https://tchumim.com/post/121207</link><guid isPermaLink="true">https://tchumim.com/post/121207</guid><dc:creator><![CDATA[clickone]]></dc:creator><pubDate>Tue, 06 Apr 2021 11:13:11 GMT</pubDate></item><item><title><![CDATA[Reply to עזרה | הוספת תכונות לתיקיה ב c# on Tue, 06 Apr 2021 07:30:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid">@<bdi>dovid</bdi></a> עובד לי מצוין!! תזכו למצוות</p>
]]></description><link>https://tchumim.com/post/121195</link><guid isPermaLink="true">https://tchumim.com/post/121195</guid><dc:creator><![CDATA[נ נח]]></dc:creator><pubDate>Tue, 06 Apr 2021 07:30:56 GMT</pubDate></item><item><title><![CDATA[Reply to עזרה | הוספת תכונות לתיקיה ב c# on Tue, 06 Apr 2021 07:23:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yossiz">@<bdi>yossiz</bdi></a> הוא משתמש בCheckedListBox</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A0-%D7%A0%D7%97">@<bdi>נ-נח</bdi></a> כפי ש@yossiz אמר הבעיה היא שאתה לא יודע איך לבדוק מה בחור.<br />
הדרך לגשת לפריטים הבחורים בCheckedListBox היא או ע"י CheckedIndices (אינדקסי מיקום) או ע"י CheckedItems (הפריטים עצמם).<br />
אתה אמור לכתוב משהו כזה:</p>
<pre><code>    di.Attributes = FileAttributes.Directory;
    foreach (var element in checkedListBox1.CheckedItems)
    {
        if (element == "תיקיה לקריאה בלבד")
            di.Attributes = FileAttributes.ReadOnly;
        else if (element == "תיקיה מוסתרת")
            di.Attributes = FileAttributes.Hidden;
        else if (element == "תיקיית מערכת")
            di.Attributes = FileAttributes.System;
    }
</code></pre>
<p dir="auto">זה לא הכי חכם, אבל זה כנראה יעבוד.</p>
]]></description><link>https://tchumim.com/post/121194</link><guid isPermaLink="true">https://tchumim.com/post/121194</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Tue, 06 Apr 2021 07:23:31 GMT</pubDate></item><item><title><![CDATA[Reply to עזרה | הוספת תכונות לתיקיה ב c# on Tue, 06 Apr 2021 06:56:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A0-%D7%A0%D7%97">@<bdi>נ-נח</bdi></a> מתוך <a href="https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.listbox.selectedindex?view=net-5.0#remarks:~:text=If%20the%20SelectionMode%20property%20of%20the,the%20index%20to%20any%20selected%20item." target="_blank" rel="noopener noreferrer nofollow ugc">התיעוד</a>:</p>
<blockquote>
<p dir="auto">If the SelectionMode property of the ListBox is set to either SelectionMode.MultiSimple or SelectionMode.MultiExtended (which indicates a multiple-selection ListBox) and multiple items are selected in the list, this property can return the index to any selected item.</p>
<p dir="auto">To retrieve a collection containing the indexes of all selected items in a multiple-selection ListBox, use the SelectedIndices property. If you want to obtain the item that is currently selected in the ListBox, use the SelectedItem property. In addition, you can use the SelectedItems property to obtain all the selected items in a multiple-selection ListBox.</p>
</blockquote>
<p dir="auto">ובעברית פשוטה, "אם אפשרת בחירות מרובות אתה אמור להשתמש ב-<code>SelectedIndices</code> (מחזיר אוסף של מספרים) או ב-<code>SelectedItems</code> (מחזיר אוסף של פריטים), ולא להשתמש ב-<code>SelectedIndex</code></p>
]]></description><link>https://tchumim.com/post/121192</link><guid isPermaLink="true">https://tchumim.com/post/121192</guid><dc:creator><![CDATA[yossiz]]></dc:creator><pubDate>Tue, 06 Apr 2021 06:56:29 GMT</pubDate></item><item><title><![CDATA[Reply to עזרה | הוספת תכונות לתיקיה ב c# on Tue, 06 Apr 2021 06:33:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A0-%D7%A0%D7%97">@<bdi>נ-נח</bdi></a> אמר ב<a href="/post/121189">עזרה | הוספת תכונות לתיקיה ב c#</a>:</p>
<blockquote>
<p dir="auto">עדיין לא עובד..</p>
</blockquote>
<p dir="auto">"לא עובד" לא עוזר לאף אחד. למה צפית ומה קיבלת?</p>
<blockquote>
<p dir="auto">אגב else if לא מתאים כאן בגלל שזה לא רק אחד מהם, זה יכול להיות שלושתם. עדיף רק if</p>
</blockquote>
<p dir="auto">אין דבר כזה שערך מסוג int יש לו כמה ערכים <img src="https://tchumim.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f615.png?v=9d71ebe86e6" class="not-responsive emoji emoji-android emoji--confused" style="height:23px;width:auto;vertical-align:middle" title=":confused:" alt="😕" /></p>
]]></description><link>https://tchumim.com/post/121191</link><guid isPermaLink="true">https://tchumim.com/post/121191</guid><dc:creator><![CDATA[yossiz]]></dc:creator><pubDate>Tue, 06 Apr 2021 06:33:59 GMT</pubDate></item><item><title><![CDATA[Reply to עזרה | הוספת תכונות לתיקיה ב c# on Tue, 06 Apr 2021 06:13:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid">@<bdi>dovid</bdi></a> עדיין לא עובד..<br />
אגב else if לא מתאים כאן בגלל שזה לא רק אחד מהם, זה יכול להיות שלושתם. עדיף רק if<br />
<img src="/assets/uploads/files/1617689596772-5e5a467b-5e51-4145-a25e-26e799d64d3c-image.png" alt="5e5a467b-5e51-4145-a25e-26e799d64d3c-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://tchumim.com/post/121189</link><guid isPermaLink="true">https://tchumim.com/post/121189</guid><dc:creator><![CDATA[נ נח]]></dc:creator><pubDate>Tue, 06 Apr 2021 06:13:59 GMT</pubDate></item><item><title><![CDATA[Reply to עזרה | הוספת תכונות לתיקיה ב c# on Tue, 06 Apr 2021 05:49:03 GMT]]></title><description><![CDATA[<pre><code>    if (checkedListBox1.SelectedIndex == 0)
        di.Attributes = di.Attributes | FileAttributes.ReadOnly;
    if (checkedListBox1.SelectedIndex == 1)
        di.Attributes = di.Attributes | FileAttributes.Hidden;
    if (checkedListBox1.SelectedIndex == 2)
        di.Attributes = di.Attributes | FileAttributes.System;
</code></pre>
<p dir="auto">או יותר קצר:</p>
<pre><code>    if (checkedListBox1.SelectedIndex == 0)
        di.Attributes |= FileAttributes.ReadOnly;
    else if (checkedListBox1.SelectedIndex == 1)
        di.Attributes |= FileAttributes.Hidden;
    else if (checkedListBox1.SelectedIndex == 2)
        di.Attributes |= FileAttributes.System;
</code></pre>
<p dir="auto">הוספתי else לקוד סתם כחינוך על הדרך.<br />
בהצלחה!</p>
]]></description><link>https://tchumim.com/post/121188</link><guid isPermaLink="true">https://tchumim.com/post/121188</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Tue, 06 Apr 2021 05:49:03 GMT</pubDate></item></channel></rss>