Posted 9 years ago by Martin de Jong - Statistics Netherlands
Version: 4.0.0283
Avatar
When i use SaveToXml of the CodeSnippet of an existing ( nad new ) snippet it doesnt work. How can i test of the SaveToXml actually worked? (Testing datetimes?)

Scenario:
1. Load CodeSnippetFolder
_folder = new CodeSnippetFolder("Blaise", path, false);
2. change a snippet in it

3. save all snippets:
            string m = string.Empty;
            foreach (CodeSnippet snippet in _folder.CodeSnippets) {
                // save snippet
                try {
                    // get a new filename for the new snippet
                    if (string.IsNullOrEmpty(snippet.SourceFile)) {
                        string fn = System.IO.Path.ChangeExtension(System.IO.Path.Combine(_folder.Path, snippet.Shortcut), ".snippet");
                         fn = Shared.IO.GetSequencedFilename(fn);
                         snippet.SourceFile = fn;
                         snippet.SaveToXml(fn);
                    } else {
                        snippet.SaveToXml();
                    }
                } catch {
                    Shared.MessageBox.Show(_owner, String.Format("Snippet {0} with filename {1} could not be saved!", snippet.Shortcut, snippet.SourceFile), "Edit Snippets", MessageBoxButton.OK, MessageBoxImage.Error);
                    m = " with errors";
                }
            }
which only wortks for new ones.

[Modified at 01/13/2010 10:13 AM]

Comments (2)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Martin,

Our CodeSnippet.SaveToFile(path) method doesn't have any try...catches. Therefore I would expect it to throw an exception if there was a problem. We just start off with this:
XmlTextWriter writer = new XmlTextWriter(path, null);
and write to the writer and close it. Nothing fancy really.

If you think there is a bug in our code, please make a simple sample project that shows it happening and email that over for us to debug. Thanks!


Actipro Software Support

Posted 9 years ago by Martin de Jong - Statistics Netherlands
Avatar
Well, solved. SaveToXml with filename saves to a file, without parameter just makes the xmldocument.

This is by design, as pointed out by support.

BTW, thanks to support. They really do a good job:)
The latest build of this product (v2018.1 build 0341) was released 6 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.