<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: current dwg file name in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6798012#M8959</link>
    <description>&lt;P&gt;How about this:&lt;/P&gt;
&lt;PRE&gt;TCHAR drive[_MAX_DRIVE+1], dir[_MAX_DIR+1], fname[_MAX_FNAME+_MAX_EXT+1], ext[_MAX_EXT+1];
errno_t err = _tsplitpath_s(&lt;FONT size="2" face="Consolas"&gt;curDoc()-&amp;gt;fileName()&lt;/FONT&gt;, drive, dir, fname, ext);
_tcscat_s(fname, _MAX_FNAME+_MAX_EXT, ext);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Jan 2017 12:50:28 GMT</pubDate>
    <dc:creator>tbrammer</dc:creator>
    <dc:date>2017-01-11T12:50:28Z</dc:date>
    <item>
      <title>current dwg file name</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6797652#M8958</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can any one guide me how to get the current dwg file name in C++,&lt;BR /&gt;&lt;BR /&gt;By using this below code I am getting the full path with file name,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;const&lt;/FONT&gt; &lt;FONT color="#2b91af" face="Consolas" size="2"&gt;ACHAR&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; *dwgfilename = curDoc()-&amp;gt;fileName();&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;but I need only the file name.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2017 09:53:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6797652#M8958</guid>
      <dc:creator>waseefur.rahman</dc:creator>
      <dc:date>2017-01-11T09:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: current dwg file name</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6798012#M8959</link>
      <description>&lt;P&gt;How about this:&lt;/P&gt;
&lt;PRE&gt;TCHAR drive[_MAX_DRIVE+1], dir[_MAX_DIR+1], fname[_MAX_FNAME+_MAX_EXT+1], ext[_MAX_EXT+1];
errno_t err = _tsplitpath_s(&lt;FONT size="2" face="Consolas"&gt;curDoc()-&amp;gt;fileName()&lt;/FONT&gt;, drive, dir, fname, ext);
_tcscat_s(fname, _MAX_FNAME+_MAX_EXT, ext);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2017 12:50:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6798012#M8959</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2017-01-11T12:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: current dwg file name</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6798299#M8960</link>
      <description>That's great,&lt;BR /&gt;&lt;BR /&gt;One more help I need,&lt;BR /&gt;&lt;BR /&gt;After getting the file name,&lt;BR /&gt;I need to create a new path with that file name.&lt;BR /&gt;&lt;BR /&gt;Then copy file to that new path,&lt;BR /&gt;I have tried with the code below, but it's not working&lt;BR /&gt;&lt;BR /&gt;//source path&lt;BR /&gt;&lt;BR /&gt;const ACHAR * dwgsourcepath = curDoc ()-&amp;gt;filename ();&lt;BR /&gt;&lt;BR /&gt;//File name&lt;BR /&gt;&lt;BR /&gt;TCHAR drive[_MAX_DRIVE+1], dir[_MAX_DIR+1], fname[_MAX_FNAME+_MAX_EXT+1], ext[_MAX_EXT+1];&lt;BR /&gt;errno_t err = _tsplitpath_s(curDoc()-&amp;gt;fileName(), drive, dir, fname, ext);&lt;BR /&gt;_tcscat_s(fname, _MAX_FNAME+_MAX_EXT, ext);&lt;BR /&gt;&lt;BR /&gt;//Destination path&lt;BR /&gt;&lt;BR /&gt;const chat *dwgdestinationpath = D:\\New folder + fname [_MAX_FNAME + _MAX_EXT + 1];&lt;BR /&gt;&lt;BR /&gt;//copy file from source to destination&lt;BR /&gt;&lt;BR /&gt;std::ifstream in(dwgsourcepath);&lt;BR /&gt;std::ifstream in(dwgdestinationpath);&lt;BR /&gt;out &amp;lt;&amp;lt; in.rdbuf();&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Jan 2017 14:32:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6798299#M8960</guid>
      <dc:creator>waseefur.rahman</dc:creator>
      <dc:date>2017-01-11T14:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: current dwg file name</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6798374#M8961</link>
      <description>&lt;P&gt;I'm not an expert for std-streams. Don't know whether they work for binary data.&lt;/P&gt;
&lt;P&gt;This should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;TCHAR dwgdestinationpath[_MAX_PATH+1] = _T("D:\\New folder\\");
_tcscat_s(dwgdestinationpath, _MAX_PATH, fname);
BOOL bFailIfExists=FALSE; // set TRUE if you don't want to overwrite existing file
BOOL bCopySuccess = CopyFile(dwgsourcepath, dwgdestinationpath, bFailIfExists);
&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Jan 2017 14:57:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6798374#M8961</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2017-01-11T14:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: current dwg file name</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6800451#M8962</link>
      <description>&lt;P&gt;Great,&lt;BR /&gt;Many Thanks ,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;one more help Please,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Since "dwgdestinationpath" we are creating from below,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;TCHAR&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; dwgdestinationpath[&lt;/FONT&gt;&lt;FONT color="#6f008a" face="Consolas" size="2"&gt;_MAX_PATH&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; + 1] = &lt;/FONT&gt;&lt;FONT color="#6f008a" face="Consolas" size="2"&gt;_T&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;(&lt;/FONT&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;"D:\\New folder\\"&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#6f008a" face="Consolas" size="2"&gt;_tcscat_s&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;(dwgdestinationpath, &lt;/FONT&gt;&lt;FONT color="#6f008a" face="Consolas" size="2"&gt;_MAX_PATH&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;, fname);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;But I am getting this Destination path from below&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;kt::&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;CStr&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; sOutput&lt;BR /&gt;&lt;BR /&gt;Also attached the screen shot,&lt;BR /&gt;&lt;BR /&gt;From the coding you provided it copies the dwg file to destination without extension (i.e) .dwg&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;I would be highly thankful for your help..&lt;BR /&gt;&lt;BR /&gt;Thanks &amp;amp; Regards&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 09:31:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6800451#M8962</guid>
      <dc:creator>waseefur.rahman</dc:creator>
      <dc:date>2017-01-12T09:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: current dwg file name</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6800470#M8963</link>
      <description>&lt;P&gt;I don't understand what I see in your PNG &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://forums.autodesk.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;TCHAR&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt; dwgdestinationpath[&lt;/FONT&gt;&lt;FONT size="2" color="#6f008a" face="Consolas"&gt;_MAX_PATH&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt; + 1] = &lt;/FONT&gt;&lt;FONT size="2" color="#6f008a" face="Consolas"&gt;_T&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;(&lt;/FONT&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;"D:\\New folder\\"&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2" color="#6f008a" face="Consolas"&gt;_tcscat_s&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;(dwgdestinationpath, &lt;/FONT&gt;&lt;FONT size="2" color="#6f008a" face="Consolas"&gt;_MAX_PATH&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;, fname);&lt;/FONT&gt; &lt;/P&gt;
...&lt;BR /&gt;
&lt;P&gt;&lt;FONT size="2" face="Consolas"&gt;From the coding you provided it copies the dwg file to destination without extension (i.e) .dwg&lt;/FONT&gt; &lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I made the assumption that you use &lt;FONT face="courier new,courier"&gt;fname&lt;/FONT&gt; after the function call&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT face="courier new,courier"&gt;_tcscat_s(fname, _MAX_FNAME+_MAX_EXT, ext);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;which appended the extension to &lt;FONT face="courier new,courier"&gt;fname&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 09:40:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6800470#M8963</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2017-01-12T09:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: current dwg file name</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6801598#M8964</link>
      <description>Actually I can't directly enter the path as ("D:\\New folder"), Since it's variable..&lt;BR /&gt;I am getting this path from const char* path,&lt;BR /&gt;&lt;BR /&gt;What I Need is I need to add file name to this path.&lt;BR /&gt;&lt;BR /&gt;Then use this path in copy command as below,&lt;BR /&gt;&lt;BR /&gt;CopyFile(dwgsourcepath, path, bFailIfExists)&lt;BR /&gt;&lt;BR /&gt;Hope you got it..</description>
      <pubDate>Thu, 12 Jan 2017 16:26:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6801598#M8964</guid>
      <dc:creator>waseefur.rahman</dc:creator>
      <dc:date>2017-01-12T16:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: current dwg file name</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6803171#M8965</link>
      <description>&lt;P&gt;From your PNG it looks as you want to take the directory from &lt;FONT face="courier new,courier"&gt;sOutput.str()&lt;/FONT&gt;. I can't see what type &lt;FONT face="courier new,courier"&gt;sOutput&lt;/FONT&gt; is. You wrote that you get the path as &lt;FONT face="courier new,courier"&gt;const char*&lt;/FONT&gt;. So you have to convert it to&lt;FONT face="courier new,courier"&gt; TCHAR*&lt;/FONT&gt;. The easiest way to do this is to use &lt;FONT face="courier new,courier"&gt;CString&lt;/FONT&gt;, because it's construtor works with both: &lt;FONT face="courier new,courier"&gt;char*&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;wchar*&lt;/FONT&gt;:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;TCHAR dwgdestinationpath[_MAX_PATH + 1];
CString csPath(sOutput.str()), csBackslash(_T("\\"));
if (csPath.Right(1) != csBackslash) // append '\' if required
    csPath += csBackslash;
_tcscpy_s(dwgdestinationpath, _MAX_PATH, (LPCTSTR)csPath);  
_tcscat_s(dwgdestinationpath, _MAX_PATH, fname); &lt;/PRE&gt;
&lt;P&gt;Or just use &lt;FONT face="courier new,courier"&gt;CString&lt;/FONT&gt; everywhere to make it more readable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;CString dwgdestinationpath(sOutput.str()), csBackslash(_T("\\")); 
if (dwgdestinationpath.Right(1) != csBackslash) // append '\' if required
	dwgdestinationpath += csBackslash;
dwgdestinationpath += fname; 
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 08:58:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6803171#M8965</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2017-01-13T08:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: current dwg file name</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6803243#M8966</link>
      <description>&lt;P&gt;That's Great,&lt;BR /&gt;got the solution,&lt;BR /&gt;Highly Thankful for your Help..&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 09:41:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/current-dwg-file-name/m-p/6803243#M8966</guid>
      <dc:creator>waseefur.rahman</dc:creator>
      <dc:date>2017-01-13T09:41:50Z</dc:date>
    </item>
  </channel>
</rss>

