<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Checking for the existence of a file</title><link>https://www.infopathdev.com:443/forums/thread/35688.aspx</link><pubDate>Thu, 11 Dec 2008 17:23:13 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:35688</guid><dc:creator>PhDUltra</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/35688.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=35688</wfw:commentRss><description>&lt;p&gt;To provide additional information that might be of value. If the xml file exist the code works just fine. If the xml file does not exist I get the following error messages before getting the &amp;quot;File does not exist&amp;quot; error in the Catch block:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;First i get:&lt;/p&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;&lt;font face="courier new,courier"&gt;The internet address &lt;/font&gt;&lt;a href="http://sharepointsite/Project%20Charters/ProjectName%20Project%20Charter.xml"&gt;&lt;font face="courier new,courier"&gt;http://sharepointsite/Project Charters/ProjectName Project Charter.xml&lt;/font&gt;&lt;/a&gt;&lt;font face="courier new,courier"&gt; is not valid.&lt;/font&gt;&lt;/span&gt; 
&lt;p&gt;After clicking on the OK button associated with this message, I get:&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;&lt;font face="courier new,courier"&gt;To try to connect to other data sources, click “Try to connect”. &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;&lt;font face="courier new,courier"&gt;To use previously stored data, click “Work Offline”.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;There are the three buttons: Work Offline, Try to Connect and Show Details.&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;The detailed error message reads:&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;&lt;font face="courier new,courier"&gt;The query cannot be run for the following DataObject: Project Charter&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;&lt;font face="courier new,courier"&gt;InfoPath cannot run the specified query.&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;&lt;font face="courier new,courier"&gt;The file is not a valid XML file.&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:&amp;#39;Trebuchet MS&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-size:11.0pt;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;"&gt;&lt;font face="courier new,courier"&gt;The file cannot be accessed.&lt;/font&gt;&lt;/span&gt; 
&lt;p&gt;Thanks!&lt;/p&gt;</description></item><item><title>Checking for the existence of a file</title><link>https://www.infopathdev.com:443/forums/thread/35686.aspx</link><pubDate>Thu, 11 Dec 2008 16:40:04 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:35686</guid><dc:creator>PhDUltra</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/35686.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=35686</wfw:commentRss><description>&lt;p&gt;I am using the code below to change the location of a Secondary data connection. This works fine but if the file does not exist, the FileQueryConnection.Execute() method generates an error of its own regardless of the Try block. I would like to avoid this error (confuses the users) by checking for the existence of the file before changing the FileQueryConnection object.&lt;/p&gt;
&lt;p style="FONT-SIZE:11pt;MARGIN:0in;FONT-FAMILY:Calibri;"&gt;Locating a local file would be easy but I have not been able to find a method of checking for the file on our SharePoint server using visual basic. &lt;/p&gt;
&lt;p style="FONT-SIZE:11pt;MARGIN:0in;FONT-FAMILY:Calibri;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="FONT-SIZE:11pt;MARGIN:0in;FONT-FAMILY:Calibri;"&gt;If someone could point me in the right direction, I would be grateful.&lt;/p&gt;
&lt;p style="FONT-SIZE:11pt;MARGIN:0in;FONT-FAMILY:Calibri;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="FONT-SIZE:10pt;MARGIN:0in;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;"&gt;Dim myConnection As FileQueryConnection = Me.DataConnections(&amp;quot;Project Charter&amp;quot;)&lt;/p&gt;
&lt;p style="FONT-SIZE:10pt;MARGIN:0in;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;"&gt;myConnection.FileLocation = strPath + &amp;quot;Project Charters/&amp;quot; &amp;amp; xnProjectName.Value.Trim &amp;amp; &amp;quot; Project Charter.xml&amp;quot;&lt;/p&gt;
&lt;p style="FONT-SIZE:10pt;MARGIN:0in;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="FONT-SIZE:10pt;MARGIN:0in;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;"&gt;Try&lt;/p&gt;
&lt;p style="FONT-SIZE:10pt;MARGIN:0in 0in 0in 0.375in;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;"&gt;myConnection.Execute()&lt;/p&gt;
&lt;p style="FONT-SIZE:10pt;MARGIN:0in;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="FONT-SIZE:10pt;MARGIN:0in;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;"&gt;Catch ex As Exception&lt;/p&gt;
&lt;p style="FONT-SIZE:10pt;MARGIN:0in 0in 0in 0.375in;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;"&gt;MessageBox.Show(&amp;quot;File does not exist&amp;quot;, &amp;quot;Not Found&amp;quot;, MessageBoxButtons.OK, MessageBoxIcon.Error)&lt;/p&gt;
&lt;p style="FONT-SIZE:10pt;MARGIN:0in;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="FONT-SIZE:10pt;MARGIN:0in 0in 0in 0.375in;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;"&gt;Exit Sub&lt;/p&gt;
&lt;p style="FONT-SIZE:10pt;MARGIN:0in;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;"&gt;End Try&lt;/p&gt;</description></item></channel></rss>