aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-11-03 15:50:45 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-11-03 15:50:45 +0200
commit3db0c6fa3cc925754692d75d441cd38fb80a4bc3 (patch)
treea3ccbf9fb19593b0ae0f43d802af8abae349a18b /Software/Visual_Studio
parentfd4bdbad20a83025adbd8ec7992b4756e9d29c4d (diff)
downloadTango-3db0c6fa3cc925754692d75d441cd38fb80a4bc3.tar.gz
Tango-3db0c6fa3cc925754692d75d441cd38fb80a4bc3.zip
Fixed issue with PPC export multiple jobs invalid characters.
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs2
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels/MainViewVM.cs6
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/StringExtensions.cs22
3 files changed, 24 insertions, 6 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs
index a6ccad7de..64931cbe3 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs
@@ -809,7 +809,7 @@ namespace Tango.PPC.Jobs.ViewModels
{
var jobFile = await job.ToJobFile();
- using (FileStream fs = new FileStream(Path.Combine(result.Path, jobFile.Name) + ExplorerFileDefinition.Job.Extension, FileMode.Create))
+ using (FileStream fs = new FileStream(Path.Combine(result.Path, jobFile.Name.ToValidFileName()) + ExplorerFileDefinition.Job.Extension, FileMode.Create))
{
jobFile.WriteTo(fs);
}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels/MainViewVM.cs
index b9d59334c..9b22fcdb5 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels/MainViewVM.cs
@@ -22,7 +22,6 @@ namespace Tango.PPC.Storage.ViewModels
{
private bool _allow_exit;
private ExplorerFileItem _selectedItem;
- private static char[] _invalidChars = System.IO.Path.GetInvalidFileNameChars();
private String _currentPath;
public String CurrentPath
@@ -238,10 +237,7 @@ namespace Tango.PPC.Storage.ViewModels
if (text != null)
{
- foreach (var c in _invalidChars)
- {
- text = text.Replace(c.ToString(), "");
- }
+ text = text.ToValidFileName();
_fileName = text;
RaisePropertyChanged(nameof(FileName));
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/StringExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/StringExtensions.cs
index ef17f0279..97c8773d6 100644
--- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/StringExtensions.cs
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/StringExtensions.cs
@@ -224,6 +224,28 @@ public static class StringExtensions
);
}
+ /// <summary>
+ /// Removes any invalid file name characters from the string.
+ /// </summary>
+ /// <param name="str">The string.</param>
+ /// <returns></returns>
+ public static string ToValidFileName(this string str)
+ {
+ char[] _invalidChars = System.IO.Path.GetInvalidFileNameChars();
+
+ String validFileName = str;
+
+ if (validFileName != null)
+ {
+ foreach (var c in _invalidChars)
+ {
+ validFileName = validFileName.Replace(c.ToString(), "");
+ }
+ }
+
+ return validFileName;
+ }
+
public static String ToStringOrEmpty(this String str)
{
return str != null ? str : String.Empty;