Skip to content

Commit 51fdc8e

Browse files
committed
Error messages for existing file/folder
1 parent 6a44aa9 commit 51fdc8e

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

PasteIntoFile/Properties/Resources.Designer.cs

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PasteIntoFile/Properties/Resources.de.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,10 @@ Paste Into File</value>
112112
<data name="str_preview_text" xml:space="preserve">
113113
<value>Textvorschau ({0} Zeichen, {1} Zeilen)</value>
114114
</data>
115+
<data name="str_file_exists" xml:space="preserve">
116+
<value>Die Datei {0} existiert bereits. Soll sie überschrieben werden?</value>
117+
</data>
118+
<data name="str_file_exists_directory" xml:space="preserve">
119+
<value>Ein Ordner mit dem gleichen Namen existert bereits unter {0}.</value>
120+
</data>
115121
</root>

PasteIntoFile/Properties/Resources.resx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,11 @@ Paste Into File</value>
227227
<data name="str_preview_text" xml:space="preserve">
228228
<value>Text preview ({0} chars, {1} lines)</value>
229229
</data>
230+
<data name="str_file_exists_directory" xml:space="preserve">
231+
<value>A directory with the same name already exists at {0}.</value>
232+
</data>
233+
<data name="str_file_exists" xml:space="preserve">
234+
<value>The file {0} already exists.
235+
Do you want to overwrite it?</value>
236+
</data>
230237
</root>

PasteIntoFile/frmMain.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,17 @@ string save()
153153
// check if file exists
154154
if (File.Exists(file))
155155
{
156-
var result = MessageBox.Show(string.Format("The file {0} already exists.\nDo you want to overwrite it?", file), "File exists",
156+
var result = MessageBox.Show(string.Format(Resources.str_file_exists, file), Resources.str_main_window_title,
157157
MessageBoxButtons.YesNo, MessageBoxIcon.Error);
158158
if (result != DialogResult.Yes)
159159
{
160160
return null;
161161
}
162+
} else if (Directory.Exists(file))
163+
{
164+
MessageBox.Show(string.Format(Resources.str_file_exists_directory, file), Resources.str_main_window_title,
165+
MessageBoxButtons.OK, MessageBoxIcon.Error);
166+
return null;
162167
}
163168

164169
// create folders if required

0 commit comments

Comments
 (0)